How can I create links or direct access to a file on android?

1

I want to be able to create links or direct access of files from my folder / data with the directories of the / sdcard. In android I do not know how to create I have had several attempts use the following: TO) try { Process symlink = Runtime.getRuntime().exec("ln -s /data/data/com.Misdatos /sdcard/Misdatos"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }

But do not create anything or a direct access file like in linux nothing (I do not know if in android you have to see the symbolic links)

Other:

try {
    Os.symlink("/data/data/com.Misdatos", "/sdcard/Misdatos");
} catch (ErrnoException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

But the problem with this one is that it's for Android 5.0 and I need Android 4.0 or higher android 4.1 and up.

And my last attempt was to use the Files class but it is not included in the Android sdk.

If you know any way or observe that I have made an error in my codes or material, please let me know. Thanks

    
asked by Electronicappap 30.12.2016 в 18:18
source

2 answers

1

Can be run as Process on the command line:

Process symlink = Runtime.getRuntime().exec("ln -s /ruta/archivo /ruta/accesodirecto");

Keep in mind that Android allows symbolic links , but some file systems do not, and you will not be able to create links there. For example, they can not be created in FAT.

Seeing that you try to create the link in the sdcard, and most likely it is a FAT partition, the answer would be that can not be .

    
answered by 30.12.2016 / 18:36
source
1

This is not possible , the only way to do it is to access the file using a file browser and create a shortcut (link) with the option: "Add to the Desktop" ("Add to Desktop ").

I add two articles in which the procedure is explained:

link

link

    
answered by 30.12.2016 в 21:54