4

我在刪除以前在SIM卡上創建的聯繫人時遇到問題。無法從SIM卡中刪除聯繫人

首先我檢查存儲哪些值在DB這樣的:

private static final Uri URI_ICC_ADN = Uri.parse("content://icc/adn/"); 
private ContentResolver mContentResolver = this.getContentResolver(); 

Cursor c = mContentResolver.query(URI_ICC_ADN, null, null, null, null); 
c.moveToFirst(); 
while(c.moveToNext()) { 
    Log.i(LOG_TAG, "name = " + c.getString(c.getColumnIndex("name"))); 
} 

這爲我提供了這些日誌:

name = 1 
name = 2 
name = 3 
name = 1 
name = 2 
name = 5 
// etc 

這意味着,name = 1記錄存在D B。現在我想要使用此代碼刪除這些記錄:

int rowsDeleted = mContentResolver.delete(URI_ICC_ADN, "name=?", new String[] { "1" }); 

但不幸的是這些行不會被刪除 - rowsDeleted等於0。我也試過這個:

int rowsDeleted = mContentResolver.delete(URI_ICC_ADN, "name=1", null); 

但是結果是一樣的。我究竟做錯了什麼?

回答

1

「name」僅用於讀取查詢。對於刪除,您必須爲名稱列傳遞「標記」。查看該鏈接的實際執行情況IccProvider

相關問題