Android creates a file in internal storage with readable right

I am developing an Android application.

I store files in internal storage using the method:

getDir("myfolder", Context.MODE_WORLD_READABLE) 

Then I create a file:

 File myFile = new File("myFile"); myFile.createNewFile(); 

But when I browse my internal storage (using "File Explorer" or "ADB"), I see that "myFile" is created, but it does not have the same rights as "myFolder":

 drwxrwxr-x app_88 app_88 2011-11-10 15:39 myFolder -rw------- app_88 app_88 0 2011-11-10 15:39 myFile 

In the API files, I see the setReadable method, which can be readable for me and for the whole world, but this method is used only for API level 9, and I am developing for API level 7 and more.

This is the problem here because I do not have permission to read the file "myFile" thanks to ADB or File Explorer. I get the “Permission denied” error message and I don’t want to “root” my device because of the risks.

Any help?

+4
source share
1 answer

I think you can do the same in the file: http://developer.android.com/reference/android/content/Context.html#openFileOutput%28java.lang.String,%20int%29 (available from API level 1 )

NTN

+1
source

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


All Articles