Data not inserted into android Sqlite database

I am developing an application that requires the use of a SQLite database. I implemented data sampling, but before trying to insert data, I encounter problems. The problem that I am facing is that the new data that I entered is not saved, i.e. Nothing new is entered into the database.

This is my insert code, myDataBase is an instance of SQLiteDatabase.

 public void insertTitle(String Recipe) { ContentValues initialValues = new ContentValues(); initialValues.put(COLUMN_NAME,value); myDataBase.insert(ZRECIPE, null, initialValues); } 
+6
android sqlite
source share
3 answers

Try it like this. You need to start the transaction first, and then mark it as successful and completed.

  try { myDataBase.beginTransaction(); myDataBase.insert(ZRECIPE, null, initialValues); myDataBase.setTransactionSuccessful(); } finally { myDataBase.endTransaction(); } 
+6
source share

You forgot to complete the transaction.

+2
source share

Try this code, it can help you.

 public void insertTitle(String Recipe) { ContentValues initialValues = new ContentValues(); initialValues.put(COLUMN_NAME,Recipe); myDataBase.insert(ZRECIPE, null, initialValues); } 
-one
source share

All Articles