Question has been asked in 
StackOverflow: 
http://stackoverflow.com/questions/34547745/android-marshmallow-new-file-gives-permission-denied?noredirect=1#comment56837417_34547745
 

And xda 
developers: 
http://forum.xda-developers.com/tools/android-studio/noob-development-question-avc-t3283366

This is the current state of my code. I've been at this for 2 weeks and 
would really appreciate some help.

A try-catch loop containing:

  //where sourceContext is passed into the FileIO class 
//and filename is "Test.zip"

  Log.d("File is", sourceContext.getFilesDir() +"/"+ fileName);
  File file = new File(sourceContext.getFilesDir()+"/"+ fileName);
  Log.d("Status", "File loaded!");
  ZipFile loadedFile = new ZipFile(file); //I don't think it ever gets here 
successfully
  Log.d("Status", "ZIPFILE SHOULD BE LOADED");


Gives this in the log:

  01-04 11:38:51.788 19943-19943/package_name D/File is: 
/data/user/0/package_name/files/1136.zip
  01-04 11:38:51.788 19943-19943/package_name D/Status: File 
loaded!/data/user/0/package_name/files/1136.zip
  01-04 11:38:51.781 19943-19943/package_name W/package_name: type=1400 
audit(0.0:17007): avc: denied { open } for name="1136.zip" dev="mmcblk0p29" 
ino=57326 scontext=u:r:untrusted_app:s0:c512,c768 
tcontext=u:object_r:app_data_file:s0 tclass=file permissive=0


*This is from the caught error in the catch IOException section:*

  01-04 11:38:51.790 19943-19943/package_name D/No Story File: 
/data/user/0/package_name/files/1136.zip: open failed: EACCES (Permission 
denied)


Note: it says File loaded, but only because the File object is generated. 
Nothing else. It doesn't actually successfully load the file.


If I recall correctly, I should not need any additional permissions to access 
the app's own directory in data/data/package_name/files/ (returned by 
context.getFilesDir() as  /data/user/0/package_name/files/ ). 


The app can write *anything* to getFilesDir()'s directory just fine, the 
trouble comes from reading a zip file.


The file is present in the target directory (otherwise I would get ENOENT 
instead of EACCES). 


How do other apps deal with this? Surely I'm not the only one who has to deal 
with zip files...

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/944bb46f-e735-4c8e-9136-79766ff22cc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to