diff --git a/docs/html/training/basics/data-storage/databases.jd b/docs/html/training/basics/data-storage/databases.jd index 61fb7583f2e8a..6ea2140d6c0bc 100644 --- a/docs/html/training/basics/data-storage/databases.jd +++ b/docs/html/training/basics/data-storage/databases.jd @@ -73,25 +73,23 @@ single table:
-public static abstract class FeedEntry implements BaseColumns {
- public static final String TABLE_NAME = "entry";
- public static final String COLUMN_NAME_ENTRY_ID = "entryid";
- public static final String COLUMN_NAME_TITLE = "title";
- public static final String COLUMN_NAME_SUBTITLE = "subtitle";
- ...
+public final class FeedReaderContract {
+ // To prevent someone from accidentally instantiating the contract class,
+ // give it an empty constructor.
+ public FeedReaderContract() {}
+
+ /* Inner class that defines the table contents */
+ public static abstract class FeedEntry implements BaseColumns {
+ public static final String TABLE_NAME = "entry";
+ public static final String COLUMN_NAME_ENTRY_ID = "entryid";
+ public static final String COLUMN_NAME_TITLE = "title";
+ public static final String COLUMN_NAME_SUBTITLE = "subtitle";
+ ...
+ }
}
-To prevent someone from accidentally instantiating the contract class, give -it an empty constructor.
- -
-// Prevents the FeedReaderContract class from being instantiated.
-private FeedReaderContract() {}
-
-
-
cursor.moveToFirst(); long itemId = cursor.getLong( - cursor.getColumnIndexOrThrow(FeedReaderContract.FeedEntry._ID) + cursor.getColumnIndexOrThrow(FeedEntry._ID) );@@ -282,7 +280,7 @@ immune to SQL injection.
// Define 'where' part of query.
-String selection = FeedReaderContract.FeedEntry.COLUMN_NAME_ENTRY_ID + " LIKE ?";
+String selection = FeedEntry.COLUMN_NAME_ENTRY_ID + " LIKE ?";
// Specify arguments in placeholder order.
String[] selectionArgs = { String.valueOf(rowId) };
// Issue SQL statement.
@@ -305,10 +303,10 @@ SQLiteDatabase db = mDbHelper.getReadableDatabase();
// New value for one column
ContentValues values = new ContentValues();
-values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_TITLE, title);
+values.put(FeedEntry.COLUMN_NAME_TITLE, title);
// Which row to update, based on the ID
-String selection = FeedReaderContract.FeedEntry.COLUMN_NAME_ENTRY_ID + " LIKE ?";
+String selection = FeedEntry.COLUMN_NAME_ENTRY_ID + " LIKE ?";
String[] selectionArgs = { String.valueOf(rowId) };
int count = db.update(