初めてのアプリ作成で電話帳アプリを作成しています。
スマートフォンの連絡先を削除してもGoogle側の連絡先が削除されません。
いろいろ調べて下記の方法で削除しております。
他の方のアプリで削除すると削除後直ぐに同期処理が実行されてますが、
私が作成したアプリで削除しても同期処理が実行されません。
手動で同期処理を実行してもGoogle側は削除されませんでした。
どなたかご教授願います。
private void ContactsDeleteRun(String RawContactID, String
ContactID, String LookupKey) {
ArrayList<ContentProviderOperation> ops =
new ArrayList<ContentProviderOperation>();
String sSel = Data.RAW_CONTACT_ID + "=? and " +
Data.CONTACT_ID + "=? and " +
Data.LOOKUP_KEY + "=?";
String[] sColumn = new String[]{RawContactID, ContactID, LookupKey};
ops.add(ContentProviderOperation.newDelete(addCallerIsSyncAdapterParameter(Data.CONTENT_URI))
.withSelection(sSel, sColumn)
.build());
try {
context.getContentResolver().applyBatch(ContactsContract.AUTHORITY,
ops);
} catch (RemoteException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
} catch (OperationApplicationException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
}
private static Uri addCallerIsSyncAdapterParameter(Uri uri) {
return
uri.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,
"true").build();
}