Android- How Do I Get The Uri Of The Latest File Saved By The System?
In android, how could I get the URI last file saved to the system? I need this ability for an image editting application. As far as I can tell ContentObserver can only check if som
Solution 1:
You could iterate trough the files in the folder(s) your application is targeting and get the newest file trough the lastModified()
method then you could get it's location with the getPath()
method.
public File getNewestFileInDirectory() {
File newestFile = null;
// start loop trough files in directory
File file = new File(filePath);
if (newestFile == null || file.lastModified().after(newestFile.lastModified())) {
newestFile = file;
}
// end loop trough files in directory
return newestFile;
}
Post a Comment for "Android- How Do I Get The Uri Of The Latest File Saved By The System?"