03-31-2011 05:35 PM
I'm using the 1.1 eclipse plugin and the 8520 simulator with the 5.0 api.
My app saves a file called DATA.txt and I am trying to get rid of it.
I have tried clean.bat - it's still there.
I have tried the eclipse clean - it's still there.
I know it's there because the I open it in my app and read some init parameters, which are
bad - so I want to re-initialize this file. But i can't because I can't delete it.
Where is the file on the pc?
What is going on here?
thanks !
lucidbee
Solved! Go to Solution.
03-31-2011 05:43 PM
What is the full path to the file in your application?
03-31-2011 05:54 PM
file:///store/home/user/DATA.txt
thanks.
lucicbee
03-31-2011 06:58 PM - edited 04-01-2011 04:09 AM
AFAIK, clean.bat does not reset the SD Card or internal SD Card. It's job is to reset the applications on the handheld.
I am not aware of anything that automatically keeps a track of which files on SD Card or internal 'card' and removes these if/when the creating application is removed.
So I think if you want a new file, you are going to have to remove it manually, or have some function in your application that will clear it.
03-31-2011 07:10 PM
I cut and pasted this example from the API docs for the FileConnection class. It tells you how to create (and delete) a file.
.... the following code can be used to create a new file on a file system, where CFCard is a valid existing file system root name for a given implementation:
try {
FileConnection fconn = (FileConnection)Connector.open("file:///CFCard/new file.txt");
// If no exception is thrown, then the URI is valid, but the file may or may not exist.
if (!fconn.exists())
fconn.create(); // create the file if it doesn't exist
fconn.close();
}
catch (IOException ioe) {
}Developers should always check for the file's or directory's existence after a connection is established to determine if the file or directory actually exists. Similarly, files or directories can be deleted using the FileConnection.delete() method, and developers should close the connection immediately after deletion to prevent exceptions from accessing a connection to a non-existent file or directory.
03-31-2011 07:31 PM
By the way, sometimes it helps to change the project configuration. I am using Eclipse. To be able to find a file in my Windows file system I had to change the debug configuration to turn on the "Use PC file system for SD Cards" option. Don't think that will work in your case though because you are not using a SD card.
03-31-2011 10:49 PM
So I used fconn.delete() and deleted the trashed file. Then I removed the fconn.delete() from the code.
Seems odd to delete files this way but whatever works!
thanks,
lucidbee