Local Search in Android

Put your problem here if it does not fit any of the other categories.

Local Search in Android

Postby hasitharandika » Mon May 31, 2010 5:50 am

hi guys,

i have try to develop a local search for my Contact List. but every time search query returns nothing. cursor.movetoNext() returns false every time though the entered values is there.

this is my code

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 if (getIntent().getAction().equals(Intent.ACTION_SEARCH)) {
  2.                         String query = getIntent().getStringExtra(SearchManager.QUERY);
  3.                         Cursor cursor = getContentResolver().query(Phones.CONTENT_URI,
  4.                                         null, Phones.NAME + "='" + query.trim() + "'", null,
  5.                                         Phones.NAME + " ASC");                 
  6.                         startManagingCursor(cursor);
  7.                         boolean b = cursor.moveToNext();
  8.                         String[] columns = new String[] { Phones.NAME, Phones.NUMBER };
  9.                         int[] names = new int[] { R.id.contactName, R.id.number };
  10.                         dispCont = new DisplayContacts(this, R.layout.contacts, cursor,
  11.                                         columns, names);                       
  12.                         setListAdapter(dispCont);                      
  13.                         registerForContextMenu(getListView());
  14.                 }
  15.  
  16.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


this is my manifest.xml

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.                 <activity android:name=".contatcs.Contacts">
  2.                         <intent-filter>
  3.                                 <action android:name="android.intent.action.SEARCH" />
  4.                                 <category android:name="android.intent.category.DEFAULT" />
  5.                         </intent-filter>
  6.                 <intent-filter>
  7.                                 <action android:name="android.intent.action.SEARCH" />
  8.                                 <category android:name="android.intent.category.DEFAULT" />
  9.                         </intent-filter>
  10.                         <meta-data android:name="android.app.searchable"
  11.                                                  android:resource="@xml/quicksearch" />
  12.                 </activity>
  13.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


could you guys please help me out??
regards,
Mike
hasitharandika
Developer
Developer
 
Posts: 45
Joined: Mon Feb 15, 2010 8:37 am
Location: Sri Lanka

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 10 guests