Android Question Using ContentChooser URI, Dir/Filename

RJB

Active Member
Licensed User
Longtime User
Hi,
if I use contentchooser to select a file then I can access the file using the returned URI, Dir/Filename.
If I save those details in a file then try to use them the next time the App is run I get an error:
Code:
(SecurityException) java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{4244e500 23518:com.XXXX.XXXX/u0a82} (pid=23518, uid=10082) requires android.permission.MANAGE_DOCUMENTS or android.permission.MANAGE_DOCUMENTS
Can those details be used next time it runs? If so how?
How to set permission: android.permission.MANAGE_DOCUMENTS?
Thanks
 
Thanks I'll read through it.
Out of interest what did you put in the search box to find that? It never came up with the combinations I tried.
 
Upvote 0
i typed "android.permission.MANAGE_DOCUMENTS" in the search box. that was the best i could do.
 
Upvote 0
OK thanks. Looks like the easiest and safest thing to do will be to copy the file to SafeDirDefaultExternal then save the new location. I'll try it later.
 
Upvote 0
Yes, that seems to work, something like:
Code:
    Class_Globals: Public rpTempDir As String
    B4XPage_Created: rpTempDir = rp.GetSafeDirDefaultExternal("Temp")

........
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Dim FileCount As Int = 0
        Dim CopyFileName As String = "Image" & FileCount & ".jpg"
        Do While File.Exists(B4XPages.MainPage.rpTempDir, CopyFileName)
            FileCount = FileCount + 1
            CopyFileName = "Image" & FileCount & ".jpg"
        Loop
        File.Copy(Dir, FileName, B4XPages.MainPage.rpTempDir, CopyFileName)
........

Now just need to think about how to avoid loads of copied files building up once they are no longer needed!
 
Last edited:
Upvote 0
Back
Top