Having trouble getting contact info

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

Having trouble getting contact info

Postby jmejiaa » Sun Nov 23, 2008 7:57 am

Hello,

I am looking into putting the phone's contacts into an Array or Arraylist, I am going through Googles site and am a little confused with the managedQuery function, check out my code which is very similar to Google tutorial but it seems they have changed the way this method is defined.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. String[] projection = new String[] {
  3.  
  4.                                 android.provider.BaseColumns._ID,
  5.  
  6.                                 android.provider.Contacts.PeopleColumns.NAME,
  7.  
  8.                                 android.provider.Contacts.PhonesColumns.NUMBER
  9.  
  10.  
  11.  
  12.  
  13.  
  14.                 };
  15.  
  16.                 final EditText searchField = (EditText) findViewById(R.id.toField);
  17.  
  18.                 // Best way to retrieve a query; returns a managed query.
  19.  
  20.                 Uri mContacts = People.CONTENT_URI;  
  21.  
  22.  
  23.  
  24.                 Cursor cur = managedQuery( mContacts,
  25.  
  26.                                 new String[] { "contact_id", "phone",
  27.  
  28.                 "name"}, //Which columns to return.
  29.  
  30.                 null,       // WHERE clause--we won't specify.
  31.  
  32.                 null,null); // Order-by clause.
  33.  
  34.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


I guess what i'm looking here is if someone can explain what each of these parameters are, I have searched but maybe I'm just not getting something.
jmejiaa
Junior Developer
Junior Developer
 
Posts: 22
Joined: Sat Nov 15, 2008 6:36 pm

Top

Postby jmejiaa » Sun Nov 23, 2008 8:05 am

Seems that once I post here I find my solution, I was missing the permission to read contacts. :D
jmejiaa
Junior Developer
Junior Developer
 
Posts: 22
Joined: Sat Nov 15, 2008 6:36 pm

permissions

Postby aglesteban » Tue Nov 25, 2008 12:42 pm

By the way, where can we change the permissions in android? Thank you.
aglesteban
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Nov 21, 2008 5:11 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests