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);
    }    
}	


目录
相关文章
|
7月前
|
前端开发
cursor
cursor
34 0
|
Go C++
OPEN CURSOR vs SELECT
OPEN CURSOR vs SELECT
109 0
OPEN CURSOR vs SELECT
sql 中CURSOR 的使用
sql 中CURSOR 的使用http://www.bieryun.com/3273.html CURSOR是游标,常用于脚本处理。 这里主要介绍自己常用的方法,同时也会把网上的一般格式进行解释。
1690 0