Android的SQLite的 - 光标和放大器; ContentValues [英] Android SQLite - Cursor & ContentValues

查看:258
本文介绍了Android的SQLite的 - 光标和放大器; ContentValues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法让从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.

推荐答案

您可以使用的方法<一href="http://developer.android.com/reference/android/database/DatabaseUtils.html#cursorRowToContentValues%28android.database.Cursor,%20android.content.ContentValues%29">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();  

这篇关于Android的SQLite的 - 光标和放大器; ContentValues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆