1

Hy everbody.

I need help in my query. I receive a warning but I don't know what is wrong.

android.database.sqlite.SQLiteException: no such column: title: , while compiling: SELECT _id, display_name FROM view_data_restricted data WHERE (1) AND (account_name='ricardofilipe19@gmail.com' AND title!=GrupoSocios AND mimetype='vnd.android.cursor.item/group_membership' AND display_name like '%rui%') ORDER BY DISPLAY_NAME

here is my code

return getContentResolver().query(Data.CONTENT_URI,
     new String[]{ContactsContract.Contacts._ID,   ContactsContract.Contacts.DISPLAY_NAME},ContactsContract.Groups.ACCOUNT_NAME + "='" + accountName + "' AND " + ContactsContract.Groups.TITLE + "!=" + nomeGrupo + " AND " + Data.MIMETYPE + "='" + GroupMembership.CONTENT_ITEM_TYPE + "' AND " + ContactsContract.Contacts.DISPLAY_NAME + " like '%" + filter + "%'" ,
 null,
 "DISPLAY_NAME");

Thanks for your help.

Ricardo Graça
  • 581
  • 2
  • 9
  • 17

2 Answers2

0

Try putting a space in here and adding some quotes (`):

ContactsContract.Groups.TITLE + " !='" + nomeGrupo + "' AND "
Barak
  • 16,318
  • 9
  • 52
  • 84
0

You need to quote 'nomeGrupo' if you are including it in the SQL string.

i.e '" + nomeGrupo + "'

Vipul
  • 27,808
  • 7
  • 60
  • 75
  • Thanks for your reply. But I try this way and don't work. Appears the same error. – Ricardo Graça Jun 25 '12 at 14:21
  • ContactsContract.Groups.ACCOUNT_NAME + "='" + accountName + "' AND " + ContactsContract.Groups.TITLE + " !='" + nomeGrupo + "' AND " + Data.MIMETYPE + "='" + GroupMembership.CONTENT_ITEM_TYPE + "' AND " + ContactsContract.Contacts.DISPLAY_NAME + " like '%" + filter + "%'" , – Ricardo Graça Jun 25 '12 at 14:22
  • My guess is that with ContactsContract.Data.CONTENT_URI, I can't acess ContactsContract.Groups.TITLE information. I'm right? If yes, how I can countour this problem? – Ricardo Graça Jun 25 '12 at 14:45