Android Question What is a safe location to share a file from?

JohnC

Expert
Licensed User
Longtime User
I am developing an app that will create a file that needs to be accessible by other apps on the user's device.

Using the intellisense of B4A, it shows these two directory locations:

File.DirDefaultExternal
File.DirRootExternal

If I save my app's generated file into any of the "Internal" locations, then obviously other apps will not be able to access it due to the sandboxing/security of android.

I know that most (if not all) Samsung devices using come with an internal "SDcard" location. And if you insert a removable sd card (into phones that have an SD memory slot), that location is called "extSdCard".

So, I obviously don't want my app to attempt or assume the user has a physical sd memory card inserted into their phone. But, I also don't want to assume that the users device has even an "SDcard" location, or can I assume that?

Basically, I wanted to know what location can I have my app save a file into that other apps can access and can count on that location existing on the users device no matter what device they have?
 

JohnC

Expert
Licensed User
Longtime User
No drum roll before the answer?

Thanks!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can also use RuntimePermissions.GetSafeDirDefaultExternal. It returns the same path as File.DirDefaultExternal but it doesn't require the WRITE_EXTERNAL_STORAGE permission (on Android 4.4+) which is considered a "dangerous" permission. This is important if you want to switch to using runtime permissions at some point.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
For my particular application, it needs to be visible by another 3rd party app that I am doing an Intent/Share with, so I can't encrypt it.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Sorry for the confusion, when I said "safe", I meant to convey I was looking for a "reliable" location that I could store the file and "safe" from any headaches of my app throwing errors because the location might not exist on a user's device. Thus, I was looking for something that was "safe" for me as a programmer to use, but didn't mean "safe" in the security sense.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Since I'm using an Intent, the user has the ability to choose the app from an assortment of apps that can receive this file, so that won't be very practical.
 
Upvote 0
Top