Below method is for implementing the insert query in SQLite table............
public void storeInTable(){
DBAdapter databaseManager = DBAdapter.getSharedObject(context);
SQLiteDatabase sqdb = databaseManager.getWritableDatabase();
sqdb.beginTransaction();
try {
// Store in TableName Table
ContentValues cv = new ContentValues();
cv.put("ScheduleId", scheduleId);
cv.put("TypeId", typedId);
try {
sqdb.insertOrThrow("TableName", null, cv);
} catch (SQLiteConstraintException e) {
Log.e("Already Present in ScheduleTable", "true");
}
sqdb.setTransactionSuccessful();
} catch (SQLiteConstraintException e) {
Log.e("Already Stored", "true");
}
sqdb.endTransaction();
sqdb.close();
}
No comments:
Post a Comment