有没有办法从 SQLite 获取 ContentValues 对象?
非常有用,我们可以在 DB 中插入 ContentValues,从那里获取 CV 应该更有用。
最佳答案
您可以使用cursorRowToContentValues(Cursor cursor, ContentValues values)的方法的DatabaseUtils类。
例子
Cursor c = db.query(tableName,
tableColumn,
where,
whereArgs,
groupBy,
having,
orderBy);
ArrayList<ContentValues> retVal = new ArrayList<ContentValues>();
ContentValues map;
if(c.moveToFirst()) {
do {
map = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, map);
retVal.add(map);
} while(c.moveToNext());
}
c.close();
关于Android SQLite - 光标和内容值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7932420/