hi guys, this is my Query
String name = "Mike" ; Cursor cursor = getContentResolver().query(Phones.CONTENT_URI, null, Phones.NAME + "='" + name + "'", null, Phones.NAME + " ASC"); and name exists in the database but it always returns nothing. could you tell me whats wrong with this??? i'm just doing a simple search main class abstract public class mine extends ListActivity { /** Called when the activity is first created. */ abstract SimpleCursorAdapter myAdapter(Intent intent); Cursor cursor; TextView stat; String[] columns; int[] names; // abstract SimpleCursorAdapter makeMeAnAdapter(Intent intent); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); stat = (TextView) findViewById(R.id.label); viewContacts(); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); onNewIntent(getIntent()); } public void viewContacts() { cursor = getContentResolver().query(Phones.CONTENT_URI, null, null, null, Phones.NAME + " ASC"); startManagingCursor(cursor); int x = cursor.getCount(); if (cursor == null || x == 0) { // alert("Address Book", "Empty Address Book"); } columns = new String[] { People.NAME }; names = new int[] { R.id.label }; /* * myAdapter = new SimpleCursorAdapter(this, R.layout.main, cursor, * columns, names); setListAdapter(myAdapter); */ } @Override protected void onNewIntent(Intent intent) { // TODO Auto-generated method stub SimpleCursorAdapter adapter = myAdapter(intent); if (adapter == null) { finish(); } else { setListAdapter(adapter); } } } Display class public class Display extends mine { @Override SimpleCursorAdapter myAdapter(Intent intent) { // TODO Auto-generated method stub return (new SimpleCursorAdapter(this,R.layout.main,cursor,columns,names)); } } search class public class Search extends mine { String[] str; int id[]; @Override SimpleCursorAdapter myAdapter(Intent intent) { // TODO Auto-generated method stub SimpleCursorAdapter adapter = null; if (intent.getAction().equals(Intent.ACTION_SEARCH)) { String query = intent.getStringExtra(SearchManager.QUERY); Cursor c = searchItems(query); Log.d("CURSOR_LENGHT", Integer.toString(c.getCount())); adapter = new SimpleCursorAdapter(this, R.layout.main, c, str, id); } return (adapter); } private Cursor searchItems(String query) { Cursor cur = getContentResolver().query(People.CONTENT_URI, null, People.NAME + "='" + query + "'", null, null); startManagingCursor(cur); int x = cur.getCount(); if (cur == null || x == 0) { // alert("Address Book", "Empty Address Book"); } if (cur.moveToNext()) { do { Log.d("CURSOR_SSSS", Integer.toString(x)); } while (cur.moveToNext()); } str = new String[] { People.NAME }; id = new int[] { R.id.label }; return cur; } } androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/ app_name" android:debuggable="true"> <activity android:name=".Display" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.default_searchable" android:value=".Search" /> </activity> <activity android:name=".Search" android:label="Search" android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> </activity> </application> <uses-sdk android:minSdkVersion="4" /> <uses-permission android:name="android.permission.READ_CONTACTS"></ uses-permission> </manifest> regards, Randika -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en