Android Question Physical location of RunTimePermissions.GetSafeDirDefaultExternal("")

Frank Cazabon

Member
Licensed User
Longtime User
Hi,
I have a config file stored using this code on an android tablet:

B4X:
Dim rp As RuntimePermissions
ConfigFilePath = rp.GetSafeDirDefaultExternal("")
File.WriteMap(ConfigFilePath, ConfigFileName, configMap)

Where does this file physically end up? I need to manually change a value in the file and can't find it.
 

Frank Cazabon

Member
Licensed User
Longtime User
Thanks but when I go into Internal Storage/Android/data there's nothing there.
I guess I'm going to have to change the program temporarily to display where the path is, or maybe delete it so it will get recreated with the new values.
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
It seems to be telling me the file is supposed to be at /storage/emulated/0/Android/data/my.app/files but I'm not able to see that folder!
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
but I'm not able to see that folder!
you are not supposed to see the file.

You can only access it from your app.

for more info about the restrictions in higher android look here:
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
so how do you use a configuration file so that users can change things like paths? I guess I'll have to create a screen in the app to allow this to be done as opposed to my old way of having a simple text file that they can edit?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What is the Package name in the Build Configurations window ?



I tested ConfigFilePath = rp.GetSafeDirDefaultExternal("") in a test program.
The Log gives: /storage/emulated/0/Android/data/b4a.TestNew/files
The folder name in data is the Package name.

And in the Windows Files Explorer I get this:
The Test.txt file is written by the test program.
The image1.jpg was added in the Windows Files Explorer and read by the test program.



Currently this works even with android:targetSdkVersion="33".
But, how long ?
Google limits more and more the access to data.
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
Mine is called IBC.PackTrack, but I can't see any Android folder under the /storage/emulated/0/ folder.
I will work out another way to get this done. Thanks
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
It should be: /storage/emulated/0/Android/data/IBC.PackTrack/files.
Try to save a file from your program to your ConfigFilePath folder.
After having written the file, maybe you need to reconnecte the USB connection, you should see the file.
This is what I did.
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
I've tried multiple times unsuccessfully. I only have one folder where the Android folder should be and it's called MIUI (which is the Xaomi android version) and there's nothing under that MIUI folder.
The other tablets that this is installed on have the android folder but no IBC.packtrack folder
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Mine is called IBC.PackTrack, but I can't see any Android folder under the /storage/emulated/0/ folder.
I will work out another way to get this done. Thanks
Are you trying to see it with a File Explorer on your phone?
Because in that case you will not be able to.
But your app will be able to read and write files in that position.
If you need to take out that file from your phone then you need to connect your phone to PC and take it exploring with Windows File Manager.

***EDIT***
In my phone I can see all the folders of installed apps, but then every Files folder appear to be empty.
Google is closing more doors everytime.
So probably the best solution is to move your file to an accessible area, but that will request user intervent to give permission (if I am correct).
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
I have attached a small test program called TestRPFolder.

This is the Build Configuration:



The program saves a text file and can read it back.
And I see the file in the windows File Explorer, of course connected via USB:



And further down a folder with the package name:

 

Attachments

  • TestRPFolder.zip
    9.2 KB · Views: 123
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Upvote 0

mangojack

Expert
Licensed User
Longtime User
It should be: /storage/emulated/0/Android/data/.......

Thanks but when I go into Internal Storage/Android/data there's nothing there.

Are you trying to see it with a File Explorer on your phone?
Because in that case you will not be able to.

This was the case on our Samsung phones , using the default file explorer the Main Storage/Android/Data folder is empty.
Installing CX File Explorer (Play Store) displays all folders , including created folders using rp. GetSafeDirDefaultExternal("")

It also allows you to transfer files to / from you PC if needed.

 
Last edited:
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
I tried it connecting my phone to my PC but still could not see the relevant folder. Thanks anyhow. I will try to change the way I allow the user to set the configuration for their specific set up.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Just to understand what you have done:
Did you test the project i sent in post #12 ?
If yes, did you press the Read button ?
Did you see First line and second line in the Logs ?
You may unplug the USB connection and connect again.
Then you should see the folder on the PC with the Windows File Explorer.
You will not see it with File explorer on the phone.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Thanks but when I go into Internal Storage/Android/data there's nothing there.
I guess I'm going to have to change the program temporarily to display where the path is, or maybe delete it so it will get recreated with the new values.
since Android version 12 iy's not available to see
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
since Android version 12 iy's not available to see

Running Android version 13 on 2 phones (Samsung and Oppo). The default file manager does Not show the content of Storage/Android/Data.

CX FileManager (google play store) displays all content, including various folders that I have created with rp. GetSafeDirDefaultExternal("").

I use this app to transfer db files to and from my PC over Wifi.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
folder - yes, but not the content of these folders
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
folder - yes, but not the content of these folders

Yes, also the folders contents. I can see the folder I have created, plus my files contained in these folders.

EDIT:

I have just rechecked this, I can see and access files in 2 folders I have created, but not 3 other app folders.
I will have to work out why this is so, and maybe change my direction for saving backups as well.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…