1. Are you ready for the Galaxy S20? Here is everything we know so far!

Copy Result of ACTION_GET_CONTENT to App Filedir

Discussion in 'Android Development' started by drblau, Oct 19, 2020.

  1. drblau

    drblau Lurker
    Thread Starter

    Recently I wanted to allow the user to pick a file and for internal reasons I have to copy it in to the Apps Directory (getFilesDir()). I let the User Pick any File with the Intent.ACTION_GET_CONTENT and the Type "*/*" so that the user really can pick anything.

    From my Intent I mostly get a Uri around the lines of content://com.android.externalstorage.documents/document... and I copy these pretty easily like this:
    [​IMG]

    Everything works wonderful if I get the scheme I said, but if I'm unlucky I get something along the lines content://com.android.providers.media.documents/document/image:15199 or any other android.providers.
    Since these are obviously not a real file, because they don't have any filetype, I'm at a loss how to copy them. I have found a Function (https://www.dev2qa.com/how-to-get-real-file-path-from-android-uri/) that gives me the real Path, but every time I try to copy with that Path I get a Permission Denied Error, even though I ask for write and read external Storage permissions and the user allows them to me. So how would it be better to copy the files?
     


Loading...

Share This Page

Loading...