Android - SQLite query to look for the deleted flag - Exception DELETED column not found -
i'm trying filter out contacts , data android's contacts storage database. i'm using deleted filter.
from here says there access using data.deleted
either i'm doing wrong can't figure out or documentation seems wrong.
i'm using cursor each query , don't know 1 causing exception. here cursors:
final cursor cursorphonenumber = contentresolver.query(phone.content_uri, projectionphonenumber, data.mimetype + " =? , " + phone.deleted + " != 1", new string[]{phone.content_item_type}, phonequeryorder); final cursor cursorstructuredname = contentresolver.query(data.content_uri, projectionstructuredname, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{structuredname.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionemail, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{email.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionstructuredpostal, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{structuredpostal.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionorganization, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{organization.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectioninstantmessaging, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{im.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionnickname, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{nickname.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionnote, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{note.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionphoto, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{android.provider.contactscontract.commondatakinds.photo.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionwebsites, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{website.content_item_type}, null); final cursor cursor = contentresolver.query(data.content_uri, projectionevents, data.mimetype + " =? , " + data.deleted + " != 1", new string[]{event.content_item_type}, null);
my projections, don't think relevant here in case are:
// phone numbers private static final string[] projectionphonenumber = new string[]{ phone.contact_id, // 0 phone.raw_contact_id, // 1 phone.type, // 2 phone.label, // 3 phone.number // 4 }; // structured name private static final string[] projectionstructuredname = new string[]{ structuredname.contact_id, // 0 structuredname.raw_contact_id, // 1 structuredname.display_name, // 2 structuredname.given_name, // 3 structuredname.family_name, // 4 structuredname.prefix, // 5 structuredname.middle_name, // 6 structuredname.suffix // 7 }; // email private static final string[] projectionemail = new string[]{ email.contact_id, // 0 email.raw_contact_id, // 1 email.address, // 2 email.type, // 3 email.label // 4 }; // structured postal private static final string[] projectionstructuredpostal = new string[]{ structuredpostal.contact_id, // 0 structuredpostal.raw_contact_id, // 1 structuredpostal.formatted_address, // 2 structuredpostal.type, // 3 structuredpostal.label, // 4 structuredpostal.street, // 5 structuredpostal.pobox, // 6 structuredpostal.neighborhood, // 7 structuredpostal.city, // 8 structuredpostal.region, // 9 structuredpostal.postcode, // 10 structuredpostal.country // 11 }; // organization private static final string[] projectionorganization = new string[]{ organization.contact_id, // 0 organization.raw_contact_id, // 1 organization.company, // 2 organization.department, // 3 organization.job_description, // 4 organization.office_location // 5 }; // instantmessaging private static final string[] projectioninstantmessaging = new string[]{ im.contact_id, // 0 im.raw_contact_id, // 1 im.protocol, // 2 im.custom_protocol // 3 }; // nickname private static final string[] projectionnickname = new string[]{ nickname.contact_id, // 0 nickname.raw_contact_id, // 1 nickname.name // 2 }; // note private static final string[] projectionnote = new string[]{ note.contact_id, // 0 note.raw_contact_id, // 1 note.note // 2 }; // photo private final string[] projectionphoto = new string[]{ android.provider.contactscontract.commondatakinds.photo.contact_id, android.provider.contactscontract.commondatakinds.photo.raw_contact_id }; // websites private final string[] projectionwebsites = new string[]{ website.contact_id, website.raw_contact_id, website.url, website.type }; // events private final string[] projectionevents = new string[]{ event.contact_id, event.raw_contact_id, event.start_date, event.type };
here's exception:
05-29 05:41:32.607: e/sqlitelog(1561): (1) no such column: deleted 05-29 05:41:32.611: e/databaseutils(1561): writing exception parcel 05-29 05:41:32.611: e/databaseutils(1561): android.database.sqlite.sqliteexception: no such column: deleted (code 1): , while compiling: select contact_id, raw_contact_id, data2, data3, data1 view_data data left outer join (select data_usage_stat.data_id, sum(data_usage_stat.times_used) times_used, max(data_usage_stat.last_time_used) last_time_used data_usage_stat group data_id) data_usage_stat on (data_usage_stat.data_id=data._id) (1 , mimetype_id=5) , ((mimetype =? , deleted != 1)) order contact_id asc 05-29 05:41:32.611: e/databaseutils(1561): @ android.database.sqlite.sqliteconnection.nativepreparestatement(native method) 05-29 05:41:32.611: e/databaseutils(1561): @ android.database.sqlite.sqliteconnection.acquirepreparedstatement(sqliteconnection.java:889) 05-29 05:41:32.611: e/databaseutils(1561): @ android.database.sqlite.sqliteconnection.prepare(sqliteconnection.java:500) 05-29 05:41:32.611: e/databaseutils(1561): @ android.database.sqlite.sqlitesession.prepare(sqlitesession.java:588) 05-29 05:41:32.611: e/databaseutils(1561): @ android.database.sqlite.sqlitequerybuilder.validatequerysql(sqlitequerybuilder.java:412) 05-29 05:41:32.611: e/databaseutils(1561): @ android.database.sqlite.sqlitequerybuilder.query(sqlitequerybuilder.java:389) 05-29 05:41:32.611: e/databaseutils(1561): @ com.android.providers.contacts.contactsprovider2.query(contactsprovider2.java:6438) 05-29 05:41:32.611: e/databaseutils(1561): @ com.android.providers.contacts.contactsprovider2.querylocal(contactsprovider2.java:6386) 05-29 05:41:32.611: e/databaseutils(1561): @ com.android.providers.contacts.contactsprovider2.query(contactsprovider2.java:4999) 05-29 05:41:32.611: e/databaseutils(1561): @ android.content.contentprovider$transport.query(contentprovider.java:200) 05-29 05:41:32.611: e/databaseutils(1561): @ android.content.contentprovidernative.ontransact(contentprovidernative.java:112) 05-29 05:41:32.611: e/databaseutils(1561): @ android.os.binder.exectransact(binder.java:404) 05-29 05:41:32.611: e/databaseutils(1561): @ dalvik.system.nativestart.run(native method)
edit cursor causing exception seems first cursor in list.
i think confusing accessing. based on trace, accessing contacts table defined here. think accessing raw contacts.
it clear in definition there no delete
column in contacts table , error supports that.
Comments
Post a Comment