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 firstname.lastname@example.org
Thanx in advance.
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??
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.