mardi 28 juillet 2015

insert if not exists else update in sqlite android

I'm using the following statement to insert values in my table in SQLITE:

public void insertStocuri(Integer rucsaci,Integer kituri, Integer sticle)
    {
       ContentValues newValues = new ContentValues();
        // Assign values for each row.
        newValues.put("Rucsaci", rucsaci);
        newValues.put("Kit",kituri);
        newValues.put("Sticle",sticle);

        // Insert the row into your table
        db.insert("STOCURI", null, newValues);
        ///Toast.makeText(context, "Reminder Is Successfully Saved", Toast.LENGTH_LONG).show();
    }

But now i want to change this so that if data exists update else make the insert statement. How can I modify this so it includes the update statement also? I am pretty new to android and SQLITE..any help would be much appreciated..

Aucun commentaire:

Enregistrer un commentaire