Duplicate an Android database from another application?

I have two versions of the same application.

When people switch from the free version to the paid version, I want the free database to be copied to the pro database.

Is there a way to access the database file itself if it belongs to another application?
Is the file even an application app or even accessible through the file system?

Finally, how do I get the path to the database file without hardcoding?

+4
source share
2 answers

Is there a way to access the database file itself if it belongs to another application?

Only if both applications share the user ID and sign with the same signature key.

Does the file support the file, or is it generally accessible through the file system?

It will be available through the file system ( /data/data/your.package.goes.here/databases/whatever-you-called-the.db ), but again, only if both applications share the user ID and sign with the same same signature key.

Finally, how do I get the path to the database file without hardcoding?

You need to hardcode it, or at least the variable components (package name and database name) that you already know at compile time.

+5
source

Where is the database file located? If it is on an SD card, you can access it directly. If you created a database in your personal application directory, you cannot touch it. You can probably identify the content provider in the free version of your application, which the pro version can use to pull out all the information stored in the database.

+1
source

Source: https://habr.com/ru/post/1301134/


All Articles