mardi 20 octobre 2015

Update integer values in SQLite database (java)

I am pretty new to SQLite databases, so please forgive me...

I have a database with integer values. When updating a row in the database using the code below, there is somehting I don't understand. whereArgs is of type String[], though the values you are looking for are integers, so I would expect that one should pass in a int[].

    SQ.update(table, values, whereClause, whereArgs)

Where do I go wrong?

Example code (hypothetical):

public void changeOneIntoTwo(DatabaseOperations dop) {
    SQLiteDatabase SQ = dop.getWritableDatabase();
    String selection = "ValuesColumn = ?";
    String[] args = {"1"};
    ContentValues cv = new ContentValues();
    cv.put("ValuesColumn", 2);
    SQ.update("MyTable", cv, selection, args);
}

Aucun commentaire:

Enregistrer un commentaire