How to retreive the contact list

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

How to retreive the contact list

Postby ankit_agg » Wed Jan 14, 2009 11:12 am

Please someone help me....of how to retrieve the contact list on click of button or any other widget
ankit_agg
Freshman
Freshman
 
Posts: 4
Joined: Wed Jan 14, 2009 11:02 am

Top

Postby mek » Wed Jan 14, 2009 12:12 pm

For example,
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         Cursor managedCursor = null;
  3.  
  4.         String[] cols = new String[] {
  5.  
  6.                 Contacts.People._ID,
  7.  
  8.                 Contacts.People.NAME,
  9.  
  10.                 Contacts.People.NUMBER
  11.  
  12.         };
  13.  
  14.         String strWhere = "name like 'T%'";
  15.  
  16.  
  17.  
  18.         try {
  19.  
  20.             managedCursor = managedQuery(Contacts.People.CONTENT_URI,      // URI
  21.  
  22.                                                                                 cols,                            // list of columns
  23.  
  24.                                                                                 strWhere,                         // WHERE clause
  25.  
  26.                                                                                 null,                             // arguments if ?
  27.  
  28.                                                                                 Contacts.People.NAME  // Order-by clause.
  29.  
  30.                 );
  31.  
  32.             if (managedCursor.moveToFirst()) {
  33.  
  34.                 do {
  35.  
  36.                         Log.d("test_debug", "contact_id="+managedCursor.getInt(0));
  37.  
  38.                         Log.d("test_debug", "contact_name="+managedCursor.getString(1));
  39.  
  40.                         Log.d("test_debug", "contact_mobile="+managedCursor.getString(2));
  41.  
  42.                 } while (managedCursor.moveToNext());
  43.  
  44.             }
  45.  
  46.  
  47.  
  48.         } finally {
  49.  
  50.                 if (managedCursor!=null) {
  51.  
  52.                         managedCursor.close();
  53.  
  54.                         managedCursor = null;
  55.  
  56.                 }
  57.  
  58.         }
  59.  
  60.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
mek
Freshman
Freshman
 
Posts: 3
Joined: Mon Jan 12, 2009 6:36 am
Location: Almaty, KZ

Postby MrSnowflake » Wed Jan 14, 2009 7:12 pm

If you would have taken the time to search the docs, you would have found some very good documentation about how to retrieve the contacts form the ContactProveder...
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests