android - AutoCompleteTextView with CursorAdapter works on virtual device, but not on physical device -


this autocompletetextview working fine, until created filterqueryprovider , passed adapter's setfilterqueryprovider method. i'm trying alow user input either contact's name or phone number, , have relevant contacts show up. here's relevant code:

    //set behavior recipient field.     autocompletetextview destination = (autocompletetextview) findviewbyid(r.id.destination_number);      //get list of contacts, add array adapter.     /*     arraylist<string>[] contactnames = getcontactlist();     arraylist<string> contactnumbers = getcontactnumbers(contactnames[1]);     */      //initialize cursoradapter.     final contentresolver cr = getcontentresolver();     cursor namecursor = cr.query(contactscontract.commondatakinds.phone.content_uri,             new string[]{contactscontract.commondatakinds.phone._id, contactscontract.commondatakinds.phone.display_name, contactscontract.commondatakinds.phone.number, contactscontract.commondatakinds.phone.type},             contactscontract.commondatakinds.phone.has_phone_number + "> 0", null, null);      completecursoradapter madapter = new completecursoradapter(newmessageactivity.this, namecursor, false);      namecursor.close();      filterqueryprovider filter = new filterqueryprovider() {         @override         public cursor runquery(charsequence constraint) {             string query = "(instr(" + contactscontract.commondatakinds.phone.display_name +                     ", '" + constraint + "') > 0 or instr(" +                     contactscontract.commondatakinds.phone.number                     + ", '" + constraint + "') > 0) , " + contactscontract.commondatakinds.phone.has_phone_number + "> 0";              return cr.query(contactscontract.commondatakinds.phone.content_uri,                     new string[]{contactscontract.commondatakinds.phone._id, contactscontract.commondatakinds.phone.display_name, contactscontract.commondatakinds.phone.number, contactscontract.commondatakinds.phone.type},                     query, null, null);         }     };      madapter.setfilterqueryprovider(filter);     destination.setadapter(madapter);     destination.setthreshold(2); 

completecursoradapter simple extended version of cursoradapter, , far it's been working fine. i'm assuming since have few contacts on virtual devices i'm testing on, , 100 or on actual phone, i'm thinking query taking long, , it's getting killed system.

however, if i'm correct in line of thinking, i'm not sure can solve this. appreciated!

well, strange. turns out phone must running older version of sqlite, since didn't know instr(). able work around using statements.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -