Home > Net >  How can I share a db file between 2 applications
How can I share a db file between 2 applications

Time:12-17

since Enviroment.getExternalStorageDirectory() is deprecated I have a little Problem. I have 2 applications (a lite and a pro version of an app). These apps have a database which I could export and import. When switching from lite to pro app, the user could import the "old" database into the new app. The database was stored under a folder inside his "sdcard". But now on Android 12 devices we no longer have access to that External Storage.

So how could I solve the problem?

Cause I think, context.getExternalFilesDir((Environment.DIRECTORY_DOCUMENTS) doesn't work cause the namespace of both apps are different. And I guess it will not work to open a file which is not located under the namespace of the app the file is requested.

CodePudding user response:

Yes, sharing the app's shared memory with another one is not possible. Other options are using a external server / Firbase to create profile for users and store there data in it.

CodePudding user response:

The easiest way is not to have two apps. Make the single app work for both modes, and gate features at runtime based on the type of license. You can even make the upgrade an in app purchase.

  • Related