02-20-2010 03:31 AM
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
02-20-2010 04:02 AM
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
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,
02-20-2010 06:02 AM
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();
}
07-07-2010 05:52 AM
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.m icroedition.io.Connector.open("file:///"+fps.getFi le());
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;
}
};