I want to delete (e.g. mobile phone number) from the Android database. For this, I pass the request following
public class ContactDemo extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String number = "2222"; Long id = getID(number); int i = getContentResolver().delete(RawContacts.CONTENT_URI, RawContacts._ID+"=?", new String[]{id.toString()}); System.out.println("Deleted"+i); } public Long getID(String number){ Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); Cursor c = getContentResolver().query(uri, new String[]{PhoneLookup._ID}, null, null, null); while(c.moveToNext()){ return c.getLong(c.getColumnIndex(PhoneLookup._ID)); } return null; } }
but he removes all contact.
What should I use to delete only this phone number (not full contact)?
Vivek source share