Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
Sonal
Posts: 21
Registered: ‎01-20-2010
My Carrier: No

Create folder on Phone memory and access file

Hi,

I know how to access file from SDCard.

But now i need to use the file from a folder from a Phone memory ?

So please help me how to make file connection from phone memory.

And test that from Simulator.

 

Thanks

Please use plain text.
Developer
kanaksony
Posts: 531
Registered: ‎04-11-2009

Re: Create folder on Phone memory and access file

Hi Sonal,

 

There are two available roots.


1) file:///store and

2) file:///SDCard/

 

You know the mechanism for SDCard. And folowing is the way to write & read file on phone memory.


FileConnection fconn;

 

 fconn = (FileConnection)Connector.open("file:///store/home/user/myFile.txt", Connector.READ_WRITE);

 

You can view this file under menu of Home Screen -> Media -> menu -> Explore. Here you will find

 

1) Media Card and

2) Device Memory.

 

go to Device Memory -> home -> user ->myFile.txt. You can also create folder of your application under this hierarchy like -> store/home/user/{myAppNameHere}.

 

Hope it helps..!

Thanks & Regards,

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
New Developer
Sonal
Posts: 21
Registered: ‎01-20-2010
My Carrier: No

Re: Create folder on Phone memory and access file

Thanks Kanaksony,

 

But it throws File System Exception on 4.3 JDE. Is there any setting to set on JDE to access phone memory ?

 

I used

 

FileConnection directory = (FileConnection) Connector.open ("file:///store/home/Son/" ,Connector.READ_WRITE); 
            if (! directory.exists())
            {                   
                directory.mkdir();               
            }

Please use plain text.
Developer
Ekansh
Posts: 468
Registered: ‎08-07-2009
My Carrier: Blackberry Developer

Re: Create folder on Phone memory and access file

Hi Sonal,

 

 

I wrote this code for picking up the image from the SDCard.

 

May be it will help you.

 

  btnBrowse = new BigButtonField("Browse",Color.BLACK,null)
  {
    protected boolean navigationClick(int status, int time) 
    {
     try{
           fieldChangeNotify(1);
           FileSelectorPopupScreen fps = new FileSelectorPopupScreen("SDCard/");
           fps.pickFile();
           javax.microedition.io.file.FileConnection fileConnection = (javax.microedition.io.file.FileConnection)javax.microedition.io.Connector.open("file:///"+fps.getFile());
            java.io.InputStream in = fileConnection.openInputStream();
            byte[] data = new byte[(int)fileConnection.fileSize()];
            in.read(data,0,data.length); 
            selectedIcon = EncodedImage.createEncodedImage(data, 0, data.length);
         }
         catch(Exception ex){}
      return true;
      }
    
 };

 

 

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.