android.database.sqlite.SQLiteException: unknown error (code 0): Unable to convert BLOB to string -


i getting error while updating name in existing contact. code:

string namewhere = contactscontract.data.contact_id + "=? , " + contactscontract.data.mimetype + "='"             + contactscontract.commondatakinds.structuredname.content_item_type + "'";  string[] idparam = new string[]{contacts.getcontactid()};      contentvalues values = new contentvalues();     values.put(contactscontract.contacts.data.raw_contact_id, id);     values.put(contactscontract.commondatakinds.structuredname.display_name, contacts.getname());     int update = context.getcontentresolver().update(contactscontract.data.content_uri, values, namewhere, idparam); 

i have go through these links: sqliteexception unable convert blob string when contact have photo. android , other related problem.

and logs

e/androidruntime: fatal exception: main process: com.embedded.contacts, pid: 15248 android.database.sqlite.sqliteexception: unknown error (code 0): unable convert blob string ################################################################# error code : 0 (sqlite_ok) caused : unknown error (code 0): unable convert blob string ################################################################# ################################################################# error code : 0 (sqlite_ok) caused : unknown error (code 0): unable convert blob string ################################################################# error code : 0 (sqlite_ok) caused : unknown error (code 0): unable convert blob string ################################################################# ################################################################# @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:179) @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:135) @ android.content.contentproviderproxy.update(contentprovidernative.java:568)

your code modifying 2 values: raw_contact_id , display_name. problem raw_contact_id read-only. i'm assuming don't intend modify raw-contact-id anyway. if want modify contact's display_name id, try this:

string selection = data.contact_id + "=" + contacts.getcontactid() + " , " + data.mimetype + "='" + structuredname.content_item_type + "'"; contentvalues values = new contentvalues(); values.put(structuredname.display_name, contacts.getname()); // make sure getname() returns string!!! getcontentresolver().update(data.content_uri, values, selection, null); 

(verify import correct classes of data , structuredname)


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -