How to clear the call log in Android?
<p>I would like to clear ALL the call history in my Android phone programmatically and I have tried developed a simple apps for doing so. But it is not working and I hope someone can just help me to check it.</p>

<pre><code>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);
    }
}
</code></pre>

<p>}</p>
