1

I working on a browser history application, And using CursorAdaptor and getContentResolver().query to fetch the bookmark and history into AutoCompleteTextView, Also apply the selection, sortorder and work well.

But i see in a post: How to filter results of AutoCompleteTextView?

Someone said it must use setFilterQueryProvider, do any reason to do that?

Copy the code from that post :

cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
            new String[] {Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER}, 
            null,null,null);



  adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
                    new String[] {Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER}, 
                    Phone.DISPLAY_NAME + " LIKE '" + constraint + "%'", 
                    null, null);
        }
    });

Why not just put the WHERE clause to getContentResolver()? Thanks you for help! I am new to android development.

Community
  • 1
  • 1
Cheung
  • 15,293
  • 19
  • 63
  • 93

0 Answers0