I want create programmatically symbolic link in my app. Is it possible in Android (4.4+)?
In Java we can use:
Path newLink = ...;
Path target = ...;
try {
Files.createSymbolicLink(newLink, target);
} catch (IOException x) {
System.err.println(x);
} catch (UnsupportedOperationException x) {
// Some file systems do not support symbolic links.
System.err.println(x);
}
from java.nio.file
but what I should use in Android?
https://docs.oracle.com/javase/tutorial/essential/io/links.html
EDIT:
I tested using reflection/native code/OS.symlink() method
and nothing work. I always get Operation not permitted (EPERM). I think you have to have root permission for create the symlink.
The problem can be with that /mnt/sdcard
is a FUSE shim that wraps /data/media/xxx
. So I started using /data/media/xxx
but I always get Permission denied
I think it's a problem with root permissions.
android.system.ErrnoException: symlink failed: EPERM (Operation not permitted)
. I will try the native code. – TreytriOs.symlink(originalFilePath,symLinkFilePath);
? – FootingOs.symlink(originalFilePath,symLinkFilePath);
but I get againsymlink failed: EPERM (Operation not permitted)
on Samsung Galaxy S5 – Treytri