Android Question Issues with external storage

Gavins

Member
Licensed User
Longtime User
I recently had to update my app to fix some issues with dropbox. Since being forced to target SDK 30 from 28, I've fallen foul of no longer being able to access File.DirExternal. My long time users have always had their data stored in a folder under File.DirExternal, which is no longer accessible by the app on Android 11 or later.

Is there any way to access this folder to at least migrate their data to RuntimePermissions.GetSafeDirDefaultExternal? I can't rollback to the previous release now and most of my users aren't savvy enough to manage copying the folder manually to the new location on the device to access their data.

Obviously new users can just use the new path.

I've tried the External Storage library, but get the error below when compiling as soon as the lib is added to the list (I've included ContentResolver and JavaObject libraries as well as #additionalJar com.android.support:support-core-utils).

B4A Version: 11.50
Parsing code. (0.14s)
Java Version: 8
Building folders structure. (0.01s)
Compiling code. Error
Error compiling program.
Error description: Current declaration does not match previous one.
Previous: {Type=files,Rank=0, RemoteObject=False}
Current: {Type=Object,Rank=1, RemoteObject=True}
Error occurred on line: 46
Dim files() As Object = Folder.Native.RunMethod("listFiles", Null)

I couldn't get the 'SaveAs' code to work. It only offered me google drive or my downloads folder, and wasn't really of much use as it requires intervention for each save.

Has anyone got any suggestions as to how I can continue to use this folder or migrate data to a new one under GetSafeDirDefaultExternal without user intervention?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there any way to access this folder to at least migrate their data to RuntimePermissions.GetSafeDirDefaultExternal?
Why use that folder? Use XUI.DefaultFolder = File.DirInternal instead.

I've tried the External Storage library, but get the error below when compiling as soon as the lib is added to the list (I've included ContentResolver and JavaObject libraries as well as #additionalJar com.android.support:support-core-utils).
Does the example work for you? If so then there might be a name conflict with one of your modules.
 
Upvote 0

Gavins

Member
Licensed User
Longtime User
Why use that folder? Use XUI.DefaultFolder = File.DirInternal instead.

The folder also needs to be accessible to the user outside of the app so they can import files.

Does the example work for you? If so then there might be a name conflict with one of your modules.

Thanks, I have a module called files so that will be the conflict.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The folder also needs to be accessible to the user outside of the app so they can import files.
The proper way to let the user import files is with ContentChooser.
 
Upvote 0
Top