mardi 5 avril 2016

How to use savepoint and rollback with SQLite and SQLiteOpenHelper in android

I am using the following to insert values to my table

public boolean insertContact  (String name, String position, String number)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put("p_name", name);
    contentValues.put("p_position", position);
    contentValues.put("p_number", number);
    db.insert("players", null, contentValues);
    return true;
}

How I can use a savepoint and rollback? should I put savepoint like:

public boolean insertContact  (String name, String position, String number)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put("p_name", name);
    contentValues.put("p_position", position);
    contentValues.put("p_number", number);
   -->> db.savepoint Firstpoint;
    db.insert("players", null, contentValues);
    return true;
}

Are there any implication with memory usage when using a savepoint to undo a transaction in sqlite?

Aucun commentaire:

Enregistrer un commentaire