Change file resolution in application

I am trying to change the file resolution in the application. Code below:

Runtime.getRuntime().exec("chmod 777 /sdcard/test.txt"); 

This code does NOT work in my application, but there is no error log. I also checked the shell tools in / system / bin, found chmod in / system / bin, but some other data showed that chmod> toolbox. I do not quite understand about this. My application used android: sharedUserId = "android.uid.system". How to run this code or how to change the file resolution? Thank you very much.

+4
source share
2 answers
 Runtime rt = Runtime.getRuntime(); Process proc; try { proc = rt.exec(new String[] { "su", "-c", "chmod 777 " + Constants.filename }); proc.waitFor(); } catch (Exception e){ //DOSTUFFS } 

That should do the trick

+2
source

You used the path /sdcard/ in your test - is your SD card formatted with a file system that supports standard Unix permissions? ( FAT not.)

You did not specify an explicit path to chmod(1) in your line - are you sure that chmod(1) :

  • on your device
  • is available with the current value of the PATH environment variable?

You can only change permissions on your files; Are you sure that no matter which your application has an effective user ID, the file on the SD card belongs?

Finally, Android may have additional security restrictions when changing file permissions . I do not know Android very well, but perhaps changing the permission bits for files requires manifest entries that declare operations, perhaps changing file permissions is only possible through the APIs provided.

+1
source

Source: https://habr.com/ru/post/1385068/


All Articles