Android Question [solved]How judge same file

Maodge

Member
Licensed User
hi,
when i use file explorer lib (https://www.b4x.com/android/forum/threads/class-file-explorer-with-visualization.19003/), i get diffrent path for the same selected file.
for example : /mnt/sdcard/1.txt , /sdcard/1.txt, /storage/sdcard/1.txt ...
above all is the same file.
so i can't using compare filename equals and filepath equals to judge the file is same with the exists file.

then i searching web.and find some java code. these code seems can solved this problem.
B4X:
public static boolean isSymlink(File file) throws IOException 
{       
    if (file == null)           
        throw new NullPointerException("File must not be null");       
    File canon;       
    if (file.getParent() == null) 
    {           
        canon = file;       
    }
    else 
    {           
        File canonDir = file.getParentFile().getCanonicalFile();           
        canon = new File(canonDir, file.getName());       
    }       
    return !canon.getCanonicalFile().equals(file.getAbsoluteFile());   
}
my question, how can i using these code in b4a? Thanks
 

Maodge

Member
Licensed User
Thank you very much,I' m learning the use of the javaobject and reflection libraries. this code works very well in my program, It is very helpful to me
 
Upvote 0
Top