Nirmal
Nirmal

Reputation: 4829

Write a File in Phone Memory using J2ME

I have just downloaded the Samsung SDK 1.2 for Java Development.

Now, it's pure based J2ME architecture, so I have a requirement to store some files inside the memory for my application usage.

That file can have a .csv extension, so for that I have tried JSR 75's FileConnection class with following piece of code :

try {
            FileConnection fconn = (FileConnection) Connector.open("file:///CFCard/newfile.txt");
            if (!fconn.exists()) {
                fconn.create();  // create the file if it doesn't exist
            }
            fconn.close();
        } catch (IOException ioe) {
            System.out.println("exception = "+ioe);
        }

But in this case, it's giving me following exception :

exception = java.io.IOException: Root is not accessible 

So, I don't exactly, I am on the right track or not..

Thanks in advance.

Upvotes: 2

Views: 2392

Answers (2)

funkybro
funkybro

Reputation: 8671

The roots available to you vary between devices. Read the JSR 75 documentation -- the method FileSystemRegistry.listRoots() will be of interest to you.

Upvotes: 4

Oleh Prypin
Oleh Prypin

Reputation: 34126

I'm not sure about that "CFCard". For example, on my phone, I think it would be "file:///E:/newfile.txt"

I'll try to do some research about this

Upvotes: 1

Related Questions