今日学习总计

今天自己想摸索着通过局域网让手机连接安卓数据库

private void readDB(){
SQLiteDatabase db = dbHelper.getReadableDatabase();
String[] projection = {
BookEntry._ID,
BookEntry.COLUMN_NAME_TITLE,
BookEntry.COLUMN_NAME_PRICE
};
String selection = BookEntry.COLUMN_NAME_TITLE + " = ?";
String[] selectionArgs = { "My Title" };

String sortOrder =
BookEntry.COLUMN_NAME_PRICE + " DESC";

Cursor cursor = db.query(
BookEntry.TABLE_NAME, // The table to query
projection, // The array of columns to return (pass null to get all)
selection, // The columns for the WHERE clause
selectionArgs, // The values for the WHERE clause
null, // don't group the rows
null, // don't filter by row groups
sortOrder // The sort order
);

List itemIds = new ArrayList<>();
while(cursor.moveToNext()) {
long itemId = cursor.getLong(
cursor.getColumnIndexOrThrow(BookEntry._ID));
itemIds.add(itemId);
}
cursor.close();
}

posted @ 2021-03-08 21:57  禁小呆  阅读(23)  评论(0)    收藏  举报