一意のキーとそのブール値を使用してハッシュ マップを作成しました。キーでは、callog.calls の行の一意の ID を取得しています。私が望むのは、対応する真の値を持つキーが電話の最近の通話リストから削除されることです。calllog.calls から選択した行を照会して削除する方法を知る必要があります。自分で試しましたが、コードが機能しません
public void onclickhandler(View nn){
boolean state=false;
rl=(RelativeLayout) nn.getParent();
TextView tv=(TextView)rl.getChildAt(1);
cb=(CheckBox)rl.getChildAt(2);
if(cb.isChecked()){
state=true;
}
String s=tv.getText().toString();
hmp.put(s, state);
Log.i("value", tv.getText().toString());
System.out.println(state);
} //...........
//I want to delete the contacts on button click.here
//is the code for the listener..
done.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(CallLog.Calls.CONTENT_URI,
null, null, null, null);
Set keys = hmp.keySet();
Iterator it=keys.iterator();
while (it.hasNext()) {
String keyvalue=(String) it.next();
if(hmp.get(keyvalue).booleanValue()==true){
try{
cur.moveToPosition(Integer.parseInt(keyvalue));
String lookupKey = cur.getString(cur.getColumnIndex(
CallLog.Calls.CACHED_NAME));
Uri uri = Uri.withAppendedPath(
CallLog.Calls.CONTENT_URI, lookupKey);
System.out.println("The uri is " + uri.toString());
cr.delete(uri, null, null);
}
catch(Exception e)
{
System.out.println(e.getStackTrace());
}
}//if
}//while
}//on click
});