Write Below Line into your Button on Click Event.
this.getContentResolver().delete(CallLog.Calls.CONTENT_URI, null, null);
And Give Below Permission into your Android manifest.XML file.
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
Enjoy :-)
Don’t forget to provide feedback or follow this blog, if you find this blog is useful.
this.getContentResolver().delete(CallLog.Calls.CONTENT_URI, null, null);
And Give Below Permission into your Android manifest.XML file.
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
Enjoy :-)
Don’t forget to provide feedback or follow this blog, if you find this blog is useful.
hey!
ReplyDeletethis code gives an error...
something like " add cast to receiver method"
CODES THEY WAY I DID:
package com.example.deletecalllog;
import android.R;
import android.os.Bundle;
import android.provider.CallLog;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener{
Button remove;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
remove=(Button) findViewById(R.layout.button1);
remove.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
//http://androidcodeexamples.blogspot.com/2012/06/delete-all-call-log-in-android.html
this.getContentResolver().delete(CallLog.Calls.CONTENT_URI, null, null);
Toast.makeText(getApplicationContext(), "call log deleted", Toast.LENGTH_LONG).show();
}
}