Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

file storage - I cannot access : getExternalFilesDir by another APP

I want to write a FILE by one APP and read it by another APP ( mainly for testing ). I run this on the Android Studio emulator.

First I try to resume what I found so far in documentation, and I did some testing .
( This is not quit clear to me and I have some questions )

  1. The APP has to notify the SYSTEM that it wants to use STORAGE ( = FILES ) :
    In : androidManifest.xml
  1. The APPuser has to give permission :
    a) the user can set the permission using : SETTINGS
    b) the JAVA code can ask the user for permission :

ActivityCompat.requestPermissions( ..., .... WRITE_EXTERNAL_STORAGE, 1);

  1. THEN the APP can access files in dir : .....
    a) getFilesDir : Internal storage ONLY accessable by: this.APP
    b) getExternalStorageDirectory : OLD replaced by : getExternalFilesDir
    c) getExternalFilesDir : External storage accessable by any APP
    d) getExternalFilesDirs : a list of more external storage locations

===== I hope I am right about this !!!!

BUT :

  1. My main problem .....
    I can not access the getExternalFilesDir of another APP, It can see the directory but it is NOT_READABLE !!!
    ( I am also a bit confused by the documentation : it says :
    These files are internal to the application, and not typically visible to the user as media. ????
    and a few lines later it says :
    any application holding Manifest.permission.WRITE_EXTERNAL_STORAGE can write to these files.
    )
    REM : the directory can by read by FILES manager

  2. I request the user for permission :
    requestPermissions( ..., .... WRITE_EXTERNAL_STORAGE, 1);
    This will ask the user permission for : PHOTO's and MEDIA !!!!?????

thanks .....

question from:https://stackoverflow.com/questions/65948844/i-cannot-access-getexternalfilesdir-by-another-app

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...