I have 4 methods all to update separate parts of data in a certain row. (I did this because I'm new to SQ Lite and Android). How would I condense all of this into one method?
public void updateInt(int id,String newName, String oldName){
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
String query = "UPDATE " + TABLE_NAME + " SET " + COL2 +
" = '" + newName + "' WHERE " + COL1 + " = '" + id + "'" +
" AND " + COL2 + " = '" + oldName + "'";
sqLiteDatabase.execSQL(query);
}
public void updateAuth(int id,String newAuth, String oldAuth){
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
String query = "UPDATE " + TABLE_NAME + " SET " + COL3 +
" = '" + newAuth + "' WHERE " + COL1 + " = '" + id + "'" +
" AND " + COL3 + " = '" + oldAuth + "'";
sqLiteDatabase.execSQL(query);
}
public void updateUser(int id,String newUser, String oldUser){
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
String query = "UPDATE " + TABLE_NAME + " SET " + COL5 +
" = '" + newUser + "' WHERE " + COL1 + " = '" + id + "'" +
" AND " + COL5 + " = '" + oldUser + "'";
sqLiteDatabase.execSQL(query);
}
public void updateLocation(int id,String newLocation, String oldLocation){
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
String query = "UPDATE " + TABLE_NAME + " SET " + COL4 +
" = '" + newLocation + "' WHERE " + COL1 + " = '" + id + "'" +
" AND " + COL4 + " = '" + oldLocation + "'";
sqLiteDatabase.execSQL(query);
}