Dalia Hämmerle
Dalia Hämmerle

Reputation: 13

SQLiteAssetHelper - how to insert new data to existing database with AssetHelper?

I'm currently coding an android application. To read a pre-existing database, I use the SQLiteAssethelper. It works all fine but can anyone tell me how I can insert data with the SQLiteAssethelper? Thank you!

Upvotes: 0

Views: 396

Answers (1)

Sanket Mendon
Sanket Mendon

Reputation: 403

Try this:

SQLiteDatabase mDb=getWritableDatabase();
ContentValues values = new ContentValues();
values.put("column_1", "value_1");
values.put("column_2", "value_2");
long insert_result = mDb.insert(dbSchema.table_name, null, values);
mDb.close();

Upvotes: 1

Related Questions