Im trying to read a json file from an external storage without sucess. Im getting the error:
Permission Denial: opening provider com.android.externalstorage.ExternalStorageProvider from ProcessRecord{bfaa1d6 26301:com.plm.valdecillasurdemo/u0a284} (pid=26301, uid=10284) requires that you obtain access using ACTION_OPEN_DOCUMENT or related API
In a second approach I started an ACTION_OPEN_DOCUMENT Intent.
A system dialog ask me for picking a file and all is fine. I read the file correctly however I dont want be asked for a Uri. My Uri is hardcoded.
I know must be easy the solution but this problem is drives me crazy...How can I resolve this?
Thanks in advance.
My Uri is hardcoded
That is not possible. You do not have rights to such a document, even if the Uri
is valid (which it won't be, since the DocumentsProvider
did not do any work on its side to grant it). Beyond that, the user may not have a document at the location that you hard-coded.
How can I resolve this?
Use ACTION_OPEN_DOCUMENT
and allow the user to choose the document to remove.
Or, use filesystem locations that you can read and write across OS versions, mostly those defined on Context
: getFilesDir()
, getCacheDir()
, getExternalFilesDir()
, getExternalCacheDir()
, etc. In this case, you will not need to work with Uri
values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.