The NULL pointer was coming due to null "TO" field which i have changed to
new int[] {android.R.id.list}
However the error is removed ,But Still the contacts are not getting
loaded!! It displays a list of blank fields.
try{
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.main, managedCursor, projection, null);
On Mon, Oct 20, 2008 at 8:01 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]>wrote:
>
> 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
-~----------~----~----~----~------~----~------~--~---