Hello,
I am developing application which needs to delete oldest file in memory card.
If any one is having related information plz e-mail me on rbangar30@gmail.com
Thanx in advance.
Hello,
I am developing application which needs to delete oldest file in memory card.
If any one is having related information plz e-mail me on rbangar30@gmail.com
Thanx in advance.
JSR-75 FileConnection APIs has all you need to find, create, modify and delete files. Examples in the wiki: http://www.developer.nokia.com/Commu.../Data_Articles
Details in the SDK docs.
Using FlieConnection API - FileConnection.list();Gets a list of all visible files and directories contained in a directory. The directory is the connection's target as specified in Connector.open().
Now you can check the lastModified(); for each file and to identify the oldest filename.
Once you get it - use FileConnection.delete() for this file and you are done.
thanks Amitabh , but lastModified() Returns the time that the file denoted by the URL specified in the Connector.open() method was last modified.So to get oldest file I need to compare time of modification of all files in directory which is not at all feasible.
Any other solution??
Solution:
Assume that the first file name is the oldest file, store its path and last modified in two variables, Now re-curse through the complete directory once - if you find any file with lastModified() long value is smaller then the one you assumed & stored (first one) as the oldest - store its path and last modified as the oldest... and continue the loop.
At the end of the loop you will the oldest file - delete it.