Comparator<? super File> filecomparatorByLastModified = new Comparator<File>(){
public int compare(File file1, File file2) {
if(file1.isDirectory()){
if (file2.isDirectory()){
return Long.valueOf(file1.lastModified()).compareTo(file2.lastModified());
}else{
return -1;
}
}else {
if (file2.isDirectory()){
return 1;
}else{
return Long.valueOf(file1.lastModified()).compareTo(file2.lastModified());
}
}
}
};
Download the files.
Next:
- File Explorer with sorting, in alphabetical and lastModified.
Very good post.
ReplyDeleteHow can I add two buttons so that they can work for those two different sorting order. suppose I will add one button that will sort alphabetically and the other button will sort in lastDateModified. I tried but failed to do this. Can you please help? And how can I use cut, copy and paste methods so that I can cut, copy or paste any file from one directory to another directory?
ReplyDeletehello Rasam Hossain,
ReplyDeletePlease read File Explorer with sorting, in alphabetical and lastModified..
I am having a problem running this application in Eclipse. It says it has installed fine, but when I click on the launcher icon it just said "Unfortunately, AndroidExplorer has stopped." Do you have any idea why this could be happening?
ReplyDeleteHello Matthew,
ReplyDeleteI don't know what your exact case.
What min SDK level you set? please notice that start from Android 4.1, API Level: 16, you have to set permission of READ_EXTERNAL_STORAGE to read SC Card. New permission for Android 4.1, API Level: 16..
Thank you for your help. I am running Android 4.1 API Level 16. I tried adding this code
ReplyDelete""
to my Manifest file, and that did not resolve the problem. I am really new to android programming, so I am sorry if that was a completely wrong action to take.
Also, is there an easy way to populate the directory we are accessing with files for the sake development?
Thank you for all of your help!
Sorry the code was:
ReplyDeletealso if it helps... it says in Logicat:
ReplyDeleteerror opening trace file no such file or directory (2) android