Hi,
I am trying to populate Contacts stored in phone in a drop down,But I
am getting null pointer exception while runnig it,There is data in
Phone and the permission is set in AndroidManifest.xml
Though i am able to see the contacts when i directly display them
using something like this:
name = cur.getString(nameColumn);


Below is the code:

 public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        String[] projection = new String[] {
            People._ID,
            People.NAME,
            People.NUMBER,
        };


        Uri mContacts = People.CONTENT_URI;


        Cursor managedCursor = managedQuery( mContacts,//URI
                projection, //Which columns to return.
                null,       // WHERE clause--we won't specify.
                null, //arguments to selection
                People.NAME + " ASC"); // Order-by clause.
        Log.i(null, "managedCursor");


   try{
      SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.main, managedCursor, projection, null);
      Log.i(null, "SimpleCursorAdapter");
      Spinner s1 = (Spinner) findViewById(R.id.contactDropDown);

 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        s1.setAdapter(adapter);
        }catch(Exception e){
                e.printStackTrace();
        }



    }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to