Android Question Sharing data files with SDK 29 and above

Alessandro71

Well-Known Member
Licensed User
Longtime User
SDK 29 has the following feature:
  • No permission to access File.DirRootExternal, even with the STORAGE permission.
There's workaround for the manifest files, but it's temporary and issue will just be postponed to SDK 30.

I have suite of apps, composed by 2 different apps:
  1. a "writer", that writes data in a SQLite database
  2. a "reader", which access the database for data extraction and reporting

Until now, I was able to create a directory right under DirRootExternal, where the "writer" could create and populate the database, and the "reader" could subsequently read back data.
This needs to be changed for Android 10+.

While I understand the security reason behind not allowing one app to access data belonging to a different one, what alternative options are available?
Database can grow large, so sending it back and forth the 2 apps, doesn't seem to be a viable option.

Looks like a FileProvider use case, but current user workflow doesn't include a "sharing" action to send data from the "writer" to the "reader": user should be able to run the "reader" as he likes, and access data written by the "writer" anytime.
Does the "writer" have to create the DB in the "shared" directory of the FileProvider class?
And how can the "reader" address the previously defined "shared" directory?

Do I need to merge the "writer" and the "reader" into a single app, so the data sharing won't be necessary anymore, since the DB will be in the private directory of the app itself?
 

toby

Well-Known Member
Licensed User
Longtime User
There are two solutions I'm aware of:
1. Replace local sqlite with remote mysql, or
2. Merge two apps into one.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I would go for the merge too, but..could the use of Intents be another suitable way?
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Honestly my first thought went to something like this.
Where the app "owning" the DB would accept "commands" by properly formatted intents and reply through another intent.
Or even a mix of this latter idea with the former FP you mentioned.
Anyway, if the OP finds easy to merge the two existings apps, that will make things easier even for eventual upgrades.
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
As I find technically interesting the idea, building a client/server solution on an Android phones seems like overkill, even more considering that the 2 apps aren’t absolutely meant to be run at the same time.
 
Upvote 0
Top