Samples: Fix bugs in Note Pad sample app.
Change-Id: Iacb22efa30d3627dba5a5f91151da5c75722715e
diff --git a/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java b/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
index 1131356..4595a80 100644
--- a/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
+++ b/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
@@ -703,33 +703,29 @@
// If no where clause was passed in, uses the note ID column name
// for a column and the note ID for a value.
if (TextUtils.isEmpty(where)) {
- where = NotePad.Notes._ID + " = ?";
- whereArgs[0] = noteId;
+ where = NotePad.Notes._ID + " = " + noteId;
// If where clause columns were passed in, appends the note ID to the where
// clause
} else {
/*
- * Appends the note ID column name to the list of columns, with a replaceable
- * parameter. This will work even if the rest of the columns have been set with
- * actual values.
+ * Prepends the note ID column name to the search criteria. This handles two
+ * cases: a) whereArgs contains values b) whereArgs is null.
+ *
*/
- // Appends the note ID column name as an AND condition with a replaceable
- // parameter.
- where = where + " AND " + NotePad.Notes._ID + " = ?";
+ where = NotePad.Notes._ID + " = " + noteId + " AND " + where;
- // Appends the note ID value to the end of the where clause values.
- whereArgs[whereArgs.length] = noteId;
}
- // Does the update.
// Does the update and returns the number of rows updated.
count = db.update(
NotePad.Notes.TABLE_NAME, // The database table name.
values, // A map of column names and new values to use.
- where, // The where clause column names.
- whereArgs // The where clause column values to select on.
+ where, // The where clause column names. May contain
+ // placeholders for whereArgs
+ whereArgs // The where clause column values to select on, or
+ // null if the values are in the where argument.
);
break;
// If the incoming pattern is invalid, throws an exception.
diff --git a/samples/NotePad/src/com/example/android/notepad/TitleEditor.java b/samples/NotePad/src/com/example/android/notepad/TitleEditor.java
index 7437591..02c933d 100644
--- a/samples/NotePad/src/com/example/android/notepad/TitleEditor.java
+++ b/samples/NotePad/src/com/example/android/notepad/TitleEditor.java
@@ -92,10 +92,8 @@
null // No sort order is needed.
);
- // Sets up a listener for the EditText. Gets the EditText by its ID, then sets its
- // onClickListener to this Activity.
+ // Gets the View ID for the EditText box
mText = (EditText) this.findViewById(R.id.title);
- mText.setOnClickListener(this);
// Sets up a listener for the OK button. Gets the Button by its ID, then sets its
// onClickListener to this Activity.