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.

inside custom component

Java Development

Reply
New Developer
Posts: 21
Registered: ‎01-20-2010
My Device: BlackBerry Bold
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

Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

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
New Developer
Posts: 21
Registered: ‎01-20-2010
My Device: BlackBerry Bold
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();               
            }

Highlighted
Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
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.