Problem with a contacts viewer

by jamul » Sat, 20 Dec 2008 10:54:56 GMT

Sponsored Links

I'm just getting problems with my app'... and really don't understand
all about that.
When I launch my ListActivity I get : "XContacts has stopped

XContacts is just a list view of contacts which are saved in phone.
Here is the code, I hope that I'll get some responses because I'm
thinking that I haven't understood something in documentation...

package com.test.xcontacts;

import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;

public class XContacts extends ListActivity {
        private String[] _projection = new String[] {

    public void onCreate(Bundle savedInstanceState) {

        Cursor managedCursor = managedQuery(People.CONTENT_URI,
                                People.NAME + " ASC");

        String[] from = new String[] {

        int[] to = new int[] {

        ListAdapter contactsAdapter =
                        new SimpleCursorAdapter(this, 
managedCursor, from, to);

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android=" 
  <ListView android:id="@android:id/list"
  <TextView android:id="@android:id/empty"


<?xml version="1.0" encoding="UTF-8"?>
<TextView android:id="@+id/text1"
    xmlns:android="" ;


Problem with a contacts viewer

by Mark Murphy » Sat, 20 Dec 2008 23:25:40 GMT


Have you looked at the log output (e.g., adb logcat) to see what errors 
you are getting?

Mark Murphy (a Commons Guy) 
_The Busy Coder's Guide to Android Development_ Version 1.9 Published!


Sponsored Links

Problem with a contacts viewer

by jamul » Sun, 21 Dec 2008 04:31:08 GMT

 Hmm finally I looked at it and resolved my problem.
That was my projection which causes that.
I just added People._ID and that worked :)

Thanks for your help, and hope that can serve to others having same


Problem with a contacts viewer

by tek » Sun, 01 Feb 2009 08:10:51 GMT

 Ah you helped me fix it anyway.... Exception browser wasn't showing
any errors so I had nothing to go off of.

My issue was android:id was set to "@+id/list", changed this to
"@android:id/list" and it fixed it.


Problem with a contacts viewer

by tek » Sun, 01 Feb 2009 08:10:51 GMT

 Why even post that you fixed it if you aren't going to give any
details? What a waste of your time _and_ mine. Where did you add the
like People._ID?


Problem with a contacts viewer

by anderson » Thu, 05 Mar 2009 21:38:49 GMT

 i have problem with managedQuery ,too.

from document we know Parameters :

uri                The URI of the content provider to query.
projection         List of columns to return.
selection          SQL WHERE clause.
selectionArgs   The arguments to selection, if any ?s are pesent
sortOrder               SQL ORDER BY clause.

i want to query the contact, select  whose name is User and show the
how do i write the query string ??

i thought maybe :

 String queryResult[]= new String[] {People._ID};
 String queryStr = People.NUMBER + " is not null and " + People.NAME +

         Cursor c = getContentResolver().query(
                         People.DISPLAY_NAME + " asc");

but the error log :

03-05 13:31:52.736: ERROR/DatabaseUtils(90):
android.database.sqlite.SQLiteException: no such column: User: ,
while compiling: SELECT people._id AS _id FROM people LEFT OUTER JOIN
phones ON people.primary_phone=phones._id LEFT OUTER JOIN presence ON
 (presence.person=people._id) WHERE (name=Anderson) ORDER BY
display_name asc

can anyone explain this error log ?


Other Threads

1. Please add the Azerbaijani Language to LatinIME

I would do it myself but it seems that the only way to do development
on the Android project is via Linux and I'm running Eclipse on Windows
7 64-bit.  It's a basic latin alphabet that doesn't require more than
a handful of special characters.  I'll gladly provide links to the
keyboard layout.


2. Cloud API for content extraction

I am thinking of developing a cloud service to allow app developers to
inject Javascript to web pages and retrieve JSON/XML/HTML from any web

Is this something that is needed for mobile apps?


3. Android Accelerometer + Orientation

4. Making Sure a Finished App is not Draining Resources

5. Adding swype-like functionality to the LatinIME keyboard

6. Can we register our device without having third party server?

7. Begginer list view issue