Android的SQLite的 - 光标和放大器; ContentValues放大器、光标、Android、SQLite

由网友(久经风霜)分享简介:有没有什么办法让从SQLite的的ContentValues​​对象?这是非常有用的,我们可以在数据库中插入ContentValues​​,它应该是更有用从那里得到的CV。Is there any way to GET the ContentValues object from the SQLite? It's ve...

有没有什么办法让从SQLite的的ContentValues​​对象?这是非常有用的,我们可以在数据库中插入ContentValues​​,它应该是更有用从那里得到的CV。

Is there any way to GET the ContentValues object from the SQLite? It's very useful, that we can insert ContentValues in DB, and it should be more useful to get the CV from there.

推荐答案

您可以使用的方法cursorRowToContentValues(Cursor光标,ContentValues​​值)的 DatabaseUtils 类的。

You can use the method cursorRowToContentValues(Cursor cursor, ContentValues values) of the DatabaseUtils class.

例如

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();  
阅读全文

相关推荐

最新文章