I am new to Android and working on a simple To do list app in Android. Currently, I am running into a problem when trying to update the database with the value of a text field. The function is executed when the user clicks on a button. The value from the text field is fetched, that works fine. The problem is in the SQlite statement, but I couldn´t figure it out until now:
public void saveEntryClickFunction(View view) {
final TextView textViewToChange = (TextView) findViewById(R.id.task_description);
String task = textViewToChange.getText().toString();
helper = new TaskDBHelper(TaskActivity.this);
SQLiteDatabase sqlDB = helper.getWritableDatabase();
String sql = String.format("UPDATE %s SET '%s'",
TaskContract.TABLE,
TaskContract.Columns.TASK_DESCRIPTION,
task_description);
sqlDB.execSQL(sql);
updateUI();
}
Any help on this issue would be very much appreciated, thanks!
Aucun commentaire:
Enregistrer un commentaire