Reputation: 31
I have a application that has a simple database that stores text and i want to use the same database to store text from another activity, is there any way i use the same database on tow activities. i am using the database from the website http://www.tutorialspoint.com/android/android_sqlite_database.htm
Upvotes: 2
Views: 670
Reputation: 433
You need to create instance DBHelper in your other activity, and call the method insertContact. Equals existing in example activity.
Upvotes: 2
Reputation: 3022
Yeah, use it the same way you would in your first activity - you open it the same way, and the CRUD operations should be in the same Helper class, so you call them the same way.
But do yourself a favour, and use a library like https://github.com/jgilfelt/android-sqlite-asset-helper to simplify the process for you.
Upvotes: 1