Vinit Khanna
Vinit Khanna

Reputation: 81

Access the existing database in new application

I have already created android application(app 1) that takes creates database and stores data.Now i have created another android application(app 2) which requires access to the database created previously(in app1). How can I access to database in app 1 from app 2

Upvotes: 0

Views: 69

Answers (1)

Alex Klimashevsky
Alex Klimashevsky

Reputation: 2495

Just copy a database from assets to file system (context.getFileDir() for example).

EDIT

to access database in app 1 from app 2 you have 2 options:

1) create ContentProvider in app 1 which give access to data in database. This is the best solution because you can manage access to this data using permissions. Look this for more details

2) store database file on sd_card (using external file dir and so on). In this case any application have access to your database.

3) use the same certificate for both application. in this case android create the same user for both apps and they will have access to files in each other.

I suggest you to use the first solution

Upvotes: 1

Related Questions