vendredi 9 octobre 2015

How to Insert or Update table On base of Name value in Sqlite android

public long createCountry(String code, String name, String continent,
     String region) {

     ContentValues initialValues = new ContentValues();
     initialValues.put(KEY_PRODUCT_TYPE, code);
     initialValues.put(KEY_PRODUCT_NAME, name);
     initialValues.put(KEY_PRODUCT_QUANTITY, continent);
     initialValues.put(KEY_PRODCUT_COST, region);

     return mDb.insertWithOnConflict(SQLITE_TABLE, null, initialValues, SQLiteDatabase.CONFLICT_REPLACE);

     }

this is for insert or Update function but its taking new Row if name X is alredy present in table row i want it should Update Like suppose we have 3 Entry whose name column value has X,Y,Z now Suppose i want call again this function with name X then rest of value Should update not its should create another Column please help me where am doing wrong .

Aucun commentaire:

Enregistrer un commentaire