/**
* 添加到收藏夹
* @param _id
*/
@SuppressWarnings("deprecation")
private void addKeepedContacts(long _id){
ContentResolver contentResolver = ContactActivity.this.getContentResolver();
Cursor cusor = null;
@SuppressWarnings("deprecation")
String[] projection = new String[] { Contacts.People._ID, Contacts.People.NAME, Contacts.People.NUMBER };
cusor = contentResolver.query(Contacts.People.CONTENT_URI, projection, Contacts.People._ID + "=?", new String[] { _id + "" }, Contacts.People.NAME + " ASC");
cusor.moveToFirst();
ContentValues values = new ContentValues();
Uri uri = Uri.withAppendedPath(Contacts.People.CONTENT_URI, cusor.getString(cusor.getColumnIndex(Contacts.People._ID)));
// values.put(Contacts.People.NAME, newName);
values.put(Contacts.People.STARRED, 1);
// values.put(Contacts.Phones.NUMBER, newPhoneNum);
contentResolver.update(uri, values, null, null);
Toast.makeText(ContactActivity.this, ContactActivity.this.getResources().getString(R.string.add_succeed), Toast.LENGTH_SHORT).show();
}
/**
* 从收藏夹中移出
* @param _id
*/
@SuppressWarnings("deprecation")
private void removeKeepedContacts(long _id){
ContentResolver contentResolver = ContactActivity.this.getContentResolver();
Cursor cusor = null;
@SuppressWarnings("deprecation")
String[] projection = new String[] { Contacts.People._ID, Contacts.People.NAME, Contacts.People.NUMBER };
cusor = contentResolver.query(Contacts.People.CONTENT_URI, projection, Contacts.People._ID + "=?", new String[] { _id + "" }, Contacts.People.NAME + " ASC");
cusor.moveToFirst();
ContentValues values = new ContentValues();
Uri uri = Uri.withAppendedPath(Contacts.People.CONTENT_URI, cusor.getString(cusor.getColumnIndex(Contacts.People._ID)));
// values.put(Contacts.People.NAME, newName);
values.put(Contacts.People.STARRED, 0);
// values.put(Contacts.Phones.NUMBER, newPhoneNum);
contentResolver.update(uri, values, null, null);
new getKeepedContactsTask().execute((Void)null);
Toast.makeText(ContactActivity.this, ContactActivity.this.getResources().getString(R.string.remove_succeed), Toast.LENGTH_SHORT).show();
}
* 添加到收藏夹
* @param _id
*/
@SuppressWarnings("deprecation")
private void addKeepedContacts(long _id){
ContentResolver contentResolver = ContactActivity.this.getContentResolver();
Cursor cusor = null;
@SuppressWarnings("deprecation")
String[] projection = new String[] { Contacts.People._ID, Contacts.People.NAME, Contacts.People.NUMBER };
cusor = contentResolver.query(Contacts.People.CONTENT_URI, projection, Contacts.People._ID + "=?", new String[] { _id + "" }, Contacts.People.NAME + " ASC");
cusor.moveToFirst();
ContentValues values = new ContentValues();
Uri uri = Uri.withAppendedPath(Contacts.People.CONTENT_URI, cusor.getString(cusor.getColumnIndex(Contacts.People._ID)));
// values.put(Contacts.People.NAME, newName);
values.put(Contacts.People.STARRED, 1);
// values.put(Contacts.Phones.NUMBER, newPhoneNum);
contentResolver.update(uri, values, null, null);
Toast.makeText(ContactActivity.this, ContactActivity.this.getResources().getString(R.string.add_succeed), Toast.LENGTH_SHORT).show();
}
/**
* 从收藏夹中移出
* @param _id
*/
@SuppressWarnings("deprecation")
private void removeKeepedContacts(long _id){
ContentResolver contentResolver = ContactActivity.this.getContentResolver();
Cursor cusor = null;
@SuppressWarnings("deprecation")
String[] projection = new String[] { Contacts.People._ID, Contacts.People.NAME, Contacts.People.NUMBER };
cusor = contentResolver.query(Contacts.People.CONTENT_URI, projection, Contacts.People._ID + "=?", new String[] { _id + "" }, Contacts.People.NAME + " ASC");
cusor.moveToFirst();
ContentValues values = new ContentValues();
Uri uri = Uri.withAppendedPath(Contacts.People.CONTENT_URI, cusor.getString(cusor.getColumnIndex(Contacts.People._ID)));
// values.put(Contacts.People.NAME, newName);
values.put(Contacts.People.STARRED, 0);
// values.put(Contacts.Phones.NUMBER, newPhoneNum);
contentResolver.update(uri, values, null, null);
new getKeepedContactsTask().execute((Void)null);
Toast.makeText(ContactActivity.this, ContactActivity.this.getResources().getString(R.string.remove_succeed), Toast.LENGTH_SHORT).show();
}