I am working on an android app. In database I have a column that applied Unique Constraint. CreateEntry Method Working Perfectly.
Now In Create Entry Method I want to update all attributes except Unique Attribute.
My Current Code Goes Here:
Creating Table
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + DATABASE_TABLE1 + " (" + KEY_ROWID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_NOTE
+ " TEXT NULL, " + KEY_NUMBER + " TEXT NOT NULL UNIQUE);"
);
CreateEntry Method In Database Class
public long createEntry(String number, String note) throws SQLException {
ContentValues cv = new ContentValues();
cv.put(KEY_NUMBER, number);
cv.put(KEY_NOTE, note);
return callBlockerDatabase.insert(DATABASE_TABLE1, null, cv);
}
as KEY_NUMBER is unique attribute.
First attempt: i passed "123" as number and "abc" as note to CreateEntry Method.
2nd Attempt: I passed "123" as number and "xyz" as note.
In second attempt I want to Update "xyz" as note a in specified row.
Please help me to update CreateEntry Method for achieving mentioned goal ?
Aucun commentaire:
Enregistrer un commentaire