Creating Hardlinks and Symlinks in Android

Viewed 5048

I am creating an app in which I would like to make use of hardlinks and symlinks in the Android external memory filesystem. I have tried using the commands

Os.link("oldpath", "newpath");
Os.link("oldpath", "newpath");

However, when I try this, I get this error:

link failed: EPERM (Operation not permitted)

This makes me think that you need root access, although I have seen other people do this same thing, and I would not think that they would have these commands if they needed root. Any ideas?

2 Answers

android Oreo(API 26) add Files.createLink and FileSystemProvider.createLink for hard link.

android lollipop(API 21) add Os.link for hard link

API 26 also add LinkPermission("hard") and LinkPermission("symbolic"), but I do not know how to use them.

Related