我想以编程方式清除我的 Android 手机中的所有通话记录,我已经尝试为此开发一个简单的应用程序。但它不起作用,我希望有人能帮我检查一下。
public class ClearLogActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
Button clear;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
clear = (Button)findViewById(R.id.button1);
clear.setOnClickListener(this);
}
public void onClick(View view){
Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
while(cursor.moveToNext()){
getContentResolver().delete(CallLog.Calls.CONTENT_URI, null, null);
}
}
}