4

I have two versions of the same application.

When people upgrade from the free version to the paid version I'd like the free database to be copied to the pro database location.

Is there a way I can access the database file itself if it belongs to another application?
Does the file even belong to the application or is it generally accessible through the filesystem?

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

1
  • have you got any solution for this? please help me for this? Commented Nov 16, 2011 at 4:15

2 Answers 2

5

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

Only if both applications share a user ID and are signed by the same signing key.

Does the file even belong to the application or is it generally accessible through the filesystem?

It would be available via the filesystem (/data/data/your.package.goes.here/databases/whatever-you-called-the.db), but again, only if both applications share a user ID and are signed by the same signing key.

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

You have to hardcode it, or at least the variable components (package name and database name), both of which you already know at compile time.

Sign up to request clarification or add additional context in comments.

3 Comments

Could I somehow use an Intent to request a copy?
Possibly. There's nothing built in for that. But, if nothing has a database handle open, it is just a file, so you can make a copy out to the SD card based on a broadcast Intent or something.
I think I'm going to create a small activity in my free version specifically for transfer. I'll startactivityforresult with that intent, it will copy the database to common storage, the pro version will import it on return result_OK and that's that. I'll post a full solution when I get it working.
1

Where does the database file live? If it's on the SD card then you could probably access it directly. If you've created the DB in your private application directory then you won't be able to touch it. You could probably define a content provider in the free version of your app that the pro version could use to pull out all the info stored in the database.

1 Comment

I'm using android's built in SQLite database support. The application manages the database file and location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.