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
Asked
Active
Viewed 65 times
1 Answers
1
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

Alex Klimashevsky
- 2,457
- 3
- 26
- 58
-
Should i create a new empty database in assets folder ? – Vinit Khanna Mar 27 '15 at 07:40
-
how should i copy the database? – Vinit Khanna Mar 27 '15 at 07:41
-
@vinitkhanna no, use already created. put it to assets folder in your new project and copy to file system at first app launch – Alex Klimashevsky Mar 27 '15 at 07:42
-
the database is created in my mob how do i get access to that database and how to put in assets folder – Vinit Khanna Mar 27 '15 at 07:54
-
@vinitkhanna could you explain more details about this database and this 2 apps? Is it correct that you create database at the first mobile app (this app is running on the device) and you want to have an access to this db from another app on this device? – Alex Klimashevsky Mar 27 '15 at 07:58
-
yes! i have already created database using a particular application, now i want to get access to this database from a new android application. How do i go further ? and most importantly the database is created in my mobile device. – Vinit Khanna Mar 27 '15 at 08:04
-
@vinitkhanna could you reformulate the question using information above? It's importart that you want to access the db, created and stored in existing one on device. Then I will edit my answer. – Alex Klimashevsky Mar 27 '15 at 08:07
-
@ Alex - 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 do this? Please help. – Vinit Khanna Mar 27 '15 at 08:13
-
i have created the database file in external storage. Now in what way can i read the database file and access the tables to get the contents? – Vinit Khanna Mar 27 '15 at 08:52
-
@vinitkhanna look at this article http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ – Alex Klimashevsky Mar 27 '15 at 08:57
-
i got access of the database but i am unable to query the tables that were created before. I want to access the contents of the table, how do i do it? – Vinit Khanna Mar 27 '15 at 11:14
-
what kind of error? may be it will be better to start new question? – Alex Klimashevsky Mar 27 '15 at 11:25