Cursor getContentResolver

简介: /** * This interface provides random read-write access to the result set returned * by a database query. */public class cp extends ListActivity { protected void onCreate(Bundle save

/**
 * This interface provides random read-write access to the result set returned
 * by a database query.
 */
public class cp extends ListActivity {
    
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

 /**
     * This method allows the activity to take care of managing the given
     * {@link Cursor}'s lifecycle for you based on the activity's lifecycle.
     * That is, when the activity is stopped it will automatically call
     * {@link Cursor#deactivate} on the given Cursor, and when it is later restarted
     * it will call {@link Cursor#requery} for you.  When the activity is
     * destroyed, all managed Cursors will be closed automatically.
     * 
     * @param c The Cursor to be managed.
     * 
     * @see #managedQuery(android.net.Uri , String[], String, String[], String)
     * @see #stopManagingCursor
     */

        Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, null);
        startManagingCursor(c); 
        ListAdapter adapter = new SimpleCursorAdapter(this,
                android.R.layout.simple_list_item_2, c, 
                        new String[] { Phones.NAME, Phones.NUMBER }, 
                        new int[] { android.R.id.text1, android.R.id.text2 });
        setListAdapter(adapter);
    }    
}	


目录
相关文章
|
8月前
|
存储 关系型数据库 MySQL
十九、游标 Cursor
十九、游标 Cursor
59 0
|
前端开发
cursor
cursor
100 0
|
存储 SQL 数据可视化
MySQL_01--游标CURSOR--通过游标(CURSOR)实现对select选择集的迭代使用,解决在Navicat中声明游标就一直报错的问题
我的需求是,一条一条的读取并使用select选择集的结果,使用的数据库可视化软件是Navicat。 但是我在使用游标的过程中一直在游标声明处就报错,试了很多方法,改名字,调整变量顺序都不管用,最后发现,游标需要定义在存储过程(Stored Procedure)函数里。
|
SQL 存储 数据库
Oracle-cursor游标
游标的使用
1451 0
sql 中CURSOR 的使用
sql 中CURSOR 的使用http://www.bieryun.com/3273.html CURSOR是游标,常用于脚本处理。 这里主要介绍自己常用的方法,同时也会把网上的一般格式进行解释。
1736 0