summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Malin <jmalin@google.com>2010-09-28 16:02:00 -0700
committerJoe Malin <jmalin@google.com>2010-09-28 16:02:00 -0700
commitf82564473f7067348f89a49917200d5f523c6259 (patch)
treec685fd1e865534b0736b34bc1605ec68c7323940
parent6f1718bab57c08e0e958595cf11fadf0ae212eff (diff)
downloadandroid_development-f82564473f7067348f89a49917200d5f523c6259.tar.gz
android_development-f82564473f7067348f89a49917200d5f523c6259.tar.bz2
android_development-f82564473f7067348f89a49917200d5f523c6259.zip
Samples: Fix bugs in Note Pad sample app.
Change-Id: Iacb22efa30d3627dba5a5f91151da5c75722715e
-rw-r--r--samples/NotePad/src/com/example/android/notepad/NotePadProvider.java22
-rw-r--r--samples/NotePad/src/com/example/android/notepad/TitleEditor.java4
2 files changed, 10 insertions, 16 deletions
diff --git a/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java b/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
index 1131356b9..4595a8057 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 @@ public class NotePadProvider extends ContentProvider implements PipeDataWriter<C
// 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 743759114..02c933d13 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 @@ public class TitleEditor extends Activity implements View.OnClickListener {
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.