Data not inserting in Sqlite database in android

后端 未结 3 992
一整个雨季
一整个雨季 2020-12-06 13:42

I am developing an application which requires use of an SQLite database. I have implemented fetching the data, but I am facing problems when I try to insert data. The proble

相关标签:
3条回答
  • 2020-12-06 14:00

    Try with this code this may help you

    public void insertTitle(String Recipe)  
    {  
        ContentValues initialValues = new ContentValues();  
        initialValues.put(COLUMN_NAME,Recipe);  
        myDataBase.insert(ZRECIPE, null, initialValues);  
     }
    
    0 讨论(0)
  • 2020-12-06 14:02

    Try it this way. You need first start transaction, then mark it as successful and end.

       try {  
           myDataBase.beginTransaction();
           myDataBase.insert(ZRECIPE, null, initialValues);
           myDataBase.setTransactionSuccessful();
           } 
       finally {
           myDataBase.endTransaction();
           }
    
    0 讨论(0)
  • 2020-12-06 14:06

    You forgot to commit the transaction.

    0 讨论(0)
提交回复
热议问题