更新android联系人铃声

更新android联系人铃声,android,android-contentprovider,android-contacts,Android,Android Contentprovider,Android Contacts,我正在尝试更改联系人铃声,但我遇到了这个错误 android.database.sqlite.SQLiteException:没有这样的列:自定义铃声(代码1):,编译时:更新数据集data11=?,自定义铃声=?,data10=?,data1=?,data2=?其中_id= 这是我的代码: ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); B

我正在尝试更改联系人铃声,但我遇到了这个错误

android.database.sqlite.SQLiteException:没有这样的列:自定义铃声(代码1):,编译时:更新数据集data11=?,自定义铃声=?,data10=?,data1=?,data2=?其中_id=

这是我的代码:

ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

    Builder builder = ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI);
    builder.withSelection(ContactsContract.Data.CONTACT_ID + "=?" + " AND " + ContactsContract.Data.MIMETYPE + "=?", new String[]{String.valueOf(ContactID), ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE});
    builder.withValue(ContactsContract.Data.CUSTOM_RINGTONE, myringtone.getAbsolutePath());
    builder.withValue(ContactsContract.CommonDataKinds.Phone.CUSTOM_RINGTONE, myringtone.getAbsolutePath()); //that was my alternative solution because I didn't know which property to change 
    ops.add(builder.build());

    ContentProviderResult[] res;
    try
    {
        res = getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
                        }
    catch (Exception e)
    {
        e.printStackTrace();
    }
ArrayList ops=new ArrayList();
Builder=ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT\u URI);
builder.with selection(contacts contract.Data.CONTACT_ID+“=?”+”和“+contacts contract.Data.MIMETYPE+”=?”,新字符串[]{String.valueOf(ContactID),contacts contract.commondatatypes.StructuredName.CONTENT_ITEM_TYPE});
builder.withValue(contacts contract.Data.CUSTOM_铃声,myringtone.getAbsolutePath());
builder.withValue(contacts contract.commonDataTypes.Phone.CUSTOM_RINGTONE、myringtone.getAbsolutePath())//这是我的另一种解决方案,因为我不知道该更改哪个属性
ops.add(builder.build());
ContentProviderResult[]res;
尝试
{
res=getContentResolver().applyBatch(contacts contract.AUTHORITY,ops);
}
捕获(例外e)
{
e、 printStackTrace();
}

我遗漏了什么吗?

我找到了一个使用ContentValues而不是ContentProviderOperations的解决方案:

Cursor c;
    c = getContentResolver().query(
        CommonDataKinds.Phone.CONTENT_URI, 
        null, 
        CommonDataKinds.Phone.CONTACT_ID +" = ?", 
        new String[]{ContactID}, null);

    try 
    {
         c.moveToFirst();
         Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, ContactID);
         ContentValues localContentValues = new ContentValues();
         localContentValues.put(ContactsContract.Contacts.CUSTOM_RINGTONE, ringtonefileabsolutepath);
         getContentResolver().update(localUri, localContentValues, null, null); 

    } 
    catch (Exception e)
    {
          e.printStackTrace();
    }
    finally 
    {
         c.close();
    }