Insert in SQLite Database android

后端 未结 5 912
深忆病人
深忆病人 2020-12-31 09:26

im new on Android. I have some trouble with the insert statement in the database, when im running the application the values have not been inserted. Please someone can help.

5条回答
  •  心在旅途
    2020-12-31 10:03

    You can use ContentValues to insert into your database.

    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(COL_NAME, VALUE); 
    values.put(COL_NAME, VALUE);
    
    // Inserting Row
    db.insert(YOUR_TABLE, null, values);
    

提交回复
热议问题