Tuesday, June 1, 2010

[android-developers] Android Address Book Search

hi guys,

i have developed a application which loads all the contacts in the
native address book.
since i have many contacts i created a search.

my address book contains contacts like this.

Alan
Bill

and then again

Alex
Cooper
Dillon

1. even in the native address book it's the same. may i know the
reason for that. (All my contacts are in phone book)

2. i using phones.CONTENT_URI to load all the contacts. that's how i
want to do it

and assume that i have search for Alan or Bill search query returns
nothing

but if i search foe Alex,Cooper or Dillon it will return the correct
result

this is my query

private Cursor searchItems(String query) {
Cursor cur = getContentResolver().query(Phones.CONTENT_URI , null,
Phones.NAME + "='" + query.trim() + "'", 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());
}
columns = new String[] { Phones.NAME, Phones.NUMBER };
names = new int[] { R.id.contactName, R.id.number };
return cur;
}

could somebody help me out??

regards,
Mike

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment