user3570270
user3570270

Reputation: 31

Using one database for two activities in android

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

Answers (2)

Loures
Loures

Reputation: 433

You need to create instance DBHelper in your other activity, and call the method insertContact. Equals existing in example activity.

Upvotes: 2

SQLiteNoob
SQLiteNoob

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

Related Questions