Android Question List/ Read files (e.g.in DCIM)

RJB

Active Member
Licensed User
Longtime User
(I've spent many hours searching on the forum but can't find the answer, it might be there but I can't find it!)
Is it possible to list/ read files from folders, such as DCIM, in newer versions of Android? And if so how?
https://www.b4x.com/android/forum/threads/android-jar-targetsdkversion-minsdkversion.87610/#content seems to indicate that it's not possible at all in sdk 30+
It will not work with targetSdkVersion=30. Avoid using File.DirRootExternal. Either use File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
at all in sdk 30+
There is no such term. The important tutorial explains the terms.

The solution with requestLegacyExternalStorage will work with Android 11 devices. The catch is that Google is expected to disallow it when targetSdkVersion needs to be set to 30 (next year).

You can use ContentChooser or ExternalStorage to access files without needing any permission. The user will need to select the folder or file.
 
Upvote 0

Midimaster

Active Member
Licensed User
As I also still do not understand how to continue in future, I join here and ask:

The given case:
The year is 2022.
My app needs to be avaiable on the Google Playstore.
The user has no SD card, the only avaiable memory is the device build in momory.
The user has a special file (from anywhere) of no known MIMI-type and a special Extension ".abc".
The user transfers this file with USB f.e. to dir DCIM or with Whatsapp to dir DOWNLOAD.
How can I reach this file from my app?

My app now manipulates this file and needs to offer the user the resulting file for sending it to a PC or forwaring it to next friend via Whatapp, etc..
How can I save this file in a common area?

As I understand ContentChooser works only with files of a known MIME and ExternalStorage only with SD-card
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is never a good idea to post in existing threads. There should only be a question in the very first post.

As I understand ContentChooser works only with files of a known MIME
No. You can pass */*.

Try it and you will see:
B4X:
Sub Activity_Click
    Dim cc As ContentChooser
    cc.Initialize("cc")
    cc.Show("*/*", "")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Log(Dir)
        Log(FileName)
    End If
End Sub

and ExternalStorage only with SD-card
No. Try it as well.
 
Upvote 0

Midimaster

Active Member
Licensed User
Ah! thank you. There are several posts here with misleading informations

But your aswer is a clear statement.

Somebody should sum up all (future) file strategies in a separat new tutorial. Because there are a lot of requests in the last weeks related to that topic. And this amount of posts shows that the (future) method to handle file related things is not clear to a lot of users.
 
Upvote 0
Top