Tuesday, May 02, 2006

Reading and Writing files to the SD card on the a780

Just in case you needed to read/write files to the SD card on the a780, I just came across how to do that today. It's not really documented anywhere although if you use the "listRoots()" method you can find it out. Note that it's "SD" and not "SDCard" as the JSR would lead you to believe.

FileConnection sc = (FileConnection)Connector.open("file:///SD/myFile.txt");
OutputStream os = sc.openOutputStream();

5 Comments:

Blogger Frank said...

A slight correction to this. If the SD card was renamed, it wouldn't show up as /SD/ You could use code like this to identify it since there are only two roots on the A780...

String[] roots = FileSystemRegistry.listRoots();
String sdroot = null;
for (int i=0;i<roots.length;i++) {
if (!roots[i].equals("/phone/")) {
sdroot = roots[i];
}
}
FileConnection fc = (FileConnection)Connector.open("file://" + sdroot + "tmp.txt");

11:29 AM  
Blogger Mr. said...

Cool, thanks!

10:08 AM  
Blogger Jaun Law said...

Very nice thanx!
____________
lto2

5:45 AM  
Anonymous Anonymous said...

I think this is the best blog I have been through all this day.
how to get free minecraft

1:02 AM  
Blogger Unknown said...

I'd be trampled if all sites gave articles like these awesome articles.download

8:35 AM  

Post a Comment

<< Home