sqlitestatement android nothing happens when the sqlite statement is added

for better performance

I’m not so sure which part of the code you are referring to. Opening and closing the database after each interaction is terrible for performance. The SQLiteOpenHelper takes care of all this, so you don’t need to do anything manually.

Try the following alternative to insert an entry:

public boolean addEntry(){
    db = this.getWritableDatabase();
    ContentValues values = new ContentValues();

    values.put("column1", "value1");  // make sure the type corresponds to your sql column type
    values.put("column2", "value2");
    values.put("column3", "value3");
    values.put("column4Int", 1);

    long newRowId = db.insert(TABLE_NAME, null, values);
    Log.d("DBHelper", "Added row " + newRowId + " to DB.");

    return newRowId != -1;  // -1 means it failed

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top