Android SQLite - Cursor和ContentValues

int*_*_32 25 sqlite android cursor

有没有办法从SQLite获取ContentValues对象?我们可以在DB中插入ContentValues非常有用,从那里获取CV应该更有用.

Dav*_*-mu 57

您可以使用该方法cursorRowToContentValues(光标光标,ContentValues值)的的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();  
Run Code Online (Sandbox Code Playgroud)