android - Error in group by clause in query() method of ContentResolver -
i getting error in using following query. how resolve it?
string projection[] = {data.contact_id,data.display_name,phone.number,data.raw_contact_id,email.data,phone.data1,structuredpostal.street,structuredpostal.postcode}; cursor c = getcontentresolver().query( data.content_uri, projection, "(" + data.mimetype + "=? or " + data.mimetype + "=?) group ?", new string[]{email.content_item_type, phone.content_item_type, data.contact_id}, data.contact_id);
logcat :
02-06 14:18:01.175: e/androidruntime(6884): fatal exception: intentservice[contactmanagerservice] 02-06 14:18:01.175: e/androidruntime(6884): android.database.sqlite.sqliteexception: near "group": syntax error: , while compiling: select contact_id, display_name, data1, raw_contact_id, data1, data1, data4, data9 view_data data (1) , (((mimetype=? or mimetype=?) group ?)) order contact_id 02-06 14:18:01.175: e/androidruntime(6884): @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:180) 02-06 14:18:01.175: e/androidruntime(6884): @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:136) 02-06 14:18:01.175: e/androidruntime(6884): @ android.content.contentproviderproxy.query(contentprovidernative.java:358) 02-06 14:18:01.175: e/androidruntime(6884): @ android.content.contentresolver.query(contentresolver.java:311) 02-06 14:18:01.175: e/androidruntime(6884): @ com.ecosmob.contactpro.service.contactmanagerservice.onhandleintent(contactmanagerservice.java:103) 02-06 14:18:01.175: e/androidruntime(6884): @ android.app.intentservice$servicehandler.handlemessage(intentservice.java:65) 02-06 14:18:01.175: e/androidruntime(6884): @ android.os.handler.dispatchmessage(handler.java:99) 02-06 14:18:01.175: e/androidruntime(6884): @ android.os.looper.loop(looper.java:137) 02-06 14:18:01.175: e/androidruntime(6884): @ android.os.handlerthread.run(handlerthread.java:60)
it's not possible use group by
contentresolver
query. there used parenthesis injection tricks place group by
in syntactically correct place doesn't work on platform versions.
also, can use ?
placeholder literals only, not identifiers such column names.
consider approach data need in way want.
Comments
Post a Comment