2010-02-26 35 views
1

嘗試獲取時的問題合同組嘗試獲取合同組時出現問題〜未知URL內容://com.android.contacts

Uri contacts = ContactsContract.AUTHORITY_URI; 
    //Log.v("23",contacts.toString()); 
    // Make the query. 
    Cursor managedCursor = act.managedQuery(contacts, projection, // Which 
    // columns 
    // to 
    // return 
    null, // Which rows to return (all rows) 
    null // Selection arguments (none) 
    // Put the results in ascending order by name 
    , ContactsContract.Groups.TITLE + " ASC" 
    ); 

具有:

<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission> 
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission> 

我得到 ERROR/DatabaseUtils(198): java.lang.IllegalArgumentException: Unknown URL content://com.android.contacts

回答

1

您使用錯誤的Uri嘗試ContactsContract.Groups.CONTENT_URI與聯繫人一起使用從我的角度來看,s組是非常棘手的,所以仔細閱讀文檔

1

是的,錯誤的URI。下面是一個例子的名稱(從http://www.androidref.com/#MapLocation)發現:

// 
// Find contact based on name. 
// 
ContentResolver cr = getContentResolver(); 
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, 
    "DISPLAY_NAME = '" + NAME + "'", null, null); 
if (cursor.moveToFirst()) { 
    String contactId = 
     cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); 
... 

周杰倫

相關問題