Android Question Default download folder

Nickelgrass

Active Member
Licensed User
Longtime User
Hello,

I would like my app to read files from the default download folder. So I gave it AddManifestText(<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="19" />).
Then I tried the FileDialog with File.DirInternal but there is no download folder.

Basically what I would like to do is to import certain files into my app. The files should first be stored anywhere from either an email or if stored on the phone via USB. I can see these files in the Android files app in the downloads folder. So they are there. But how can I read them from my app?

Thanks
 
Solution
Your mime type may be wrong, it will only allow files it thinks are text files to be selected. Try

cc.Show("*/*", "choose profile")

agraham

Expert
Licensed User
Longtime User
You don't need maxSdkVersion, You need to request the permission but it won't work with targetSdkVersion greater than 28 so set it to 28 for your own use if the app is nit going in the Play Store.

Look at this example. Although intended to show the use of MANAGE_EXTERNAL_STORAGE it also has the code for getting WRITE_EXTERNAL_STORAGE permission, which also gives you read permission,
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
You don't need maxSdkVersion, You need to request the permission but it won't work with targetSdkVersion greater than 28 so set it to 28 for your own use if the app is nit going in the Play Store.

Look at this example. Although intended to show the use of MANAGE_EXTERNAL_STORAGE it also has the code for getting WRITE_EXTERNAL_STORAGE permission, which also gives you read permission,
Thanks for the reply. But the app is supposed to go to playstore. I will look into the example.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
But the app is supposed to go to playstore.
In that case your choices are here.

Using FileHandler should let you access Downloads. Example loading a file here but note that you may need to change the mime type in Sub Load in the FileHandler class.
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
In that case your choices are here.

Using FileHandler should let you access Downloads. Example loading a file here but note that you may need to change the mime type in Sub Load in the FileHandler class.
Thanks for the tips! The contentchooser seems work. At least on the emulator. Phone I need to test yet.

Is there any way to set the filter to a custom file type?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Is there any way to set the filter to a custom file type?
Depends what you mean by a custom file type but in any case I don't really know as my apps are for my own use so I use MANAGE_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permissions to access the file store directly so I am not familiar with either FileProvider or ContentChooser.,
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
Ok so it does not work on the actual phone. I can start the ContentChooser and see the files but I can not select the files.

ContentChooser:
    Dim cc As ContentChooser
    cc.Initialize("CC")
    cc.Show("text/*", "choose profile")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Dim fil As String = File.ReadString(Dir, FileName)
        log(fil)
    end if
 
Upvote 0
Top