How to get Contact information in array

by Arsalan » Fri, 14 Jan 2011 21:15:03 GMT


Sponsored Links
 Im new to android development, im trying to retrieve contact list with
there name and phone numbers.i try following code :

 // Get a cursor over every contact.
  Cursor cursor = getContentResolver().query(People.CONTENT_URI,null,
null, null, null);
   // Let the activity manage the cursor lifecycle.
     startManagingCursor(cursor);
     // Use the convenience properties to get the index of the
columns
  int nameIdx = cursor.getColumnIndexOrThrow(People.NAME);
     int phoneIdx = cursor. getColumnIndexOrThrow(People.NUMBER);
    String[] result = new String[cursor.getCount()];
  if (cursor.moveToFirst())
    do {
       // Extract the name.
       String name = cursor.getString(nameIdx);
        // Extract the phone number.
       String phone = cursor.getString(phoneIdx);
      result[cursor.getPosition()] = name + "-" +" "+  phone;
     } while(cursor.moveToNext());


this code should return an array with the all contacts name and its
phone number but this only return name of the contact and return NULL
in phone number,

Example Output:

 John - null

Please help me in this regards thats whats wrong in this code. Any
help in this regards will highly apreaciated, and its urgent thanks in
advance.

-- 



Re: How to get Contact information in array

by Kumar Bibek » Fri, 14 Jan 2011 21:19:29 GMT


 Either you are not using the right column, or you don't have any phone
number for John.

Morever, this class is deprecated, and it might not work properly on
emulators/devices beyond 1.5. Use ContactsContract instead.
Kumar Bibek
 http://techdroid.kbeanie.com 
 http://www.kbeanie.com 







-- 


Sponsored Links


Other Threads

1. Third-party package

Hi
I am compiling a third party package(mvcdec) for android.I placed the
package in external folder.and started compiling using the arm-tool
chain :arm-2008q3 .The source code of mvcdec contains C++ files.And i
was able to compile it in linux.They are using g++ for C++
compilation..

  While compiling i am getting errors like this:home/user/
Android_Eclair/home/RLS25E.16/mydroid/../../../arm-2008q3/arm-none-
linux-gnueabi/include/c++/4.3.2/iostream:81: undefined reference to
`std::ios_base::Init::Init()'.

I feel the error  is because the compiler we are using is gcc and not g
++..
My question is how can we explicitly specify in  the make command to
use g++ for the mvcdec..
Do i have to make any change in the Android.mk of mvcdec....

I am new to android.The android version i am using is Eclair.so please
help.....
Thanks a lot in advance....

Jesna

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Screen flicker when swapping bitmaps to draw

I am working on a Live Wallpaper app.  Basically id downloads a bunch
of different background images and then randomly picks one to
display.  They change every few minutes to another background.  THe
problem I an encountering is during the transitions.  The bitmaps
sometimes flickers when transitioning to the new one.

I have a thread class that does the drawing for me and while i swap
the bitmaps i pause the drawing thread but I still get the flicker.
Here's some of the code.  I'm not sure what else I need to do.  Any
suggestions would be great.  Thanks.

//* we don't want to paint the background while we are loading the
                //* new image into it so lets pause the drawing then restart
                //* it after were done.
                this.pausePainting();

                xTmpBitmap = BitmapFactory.decodeStream(ifp.getInputStream());
                if (xTmpBitmap == null)
                {
                        LiveWallpaper1.debugLog.log_error("Unable to create the 
bitmap,");
                        ifp.close();

                        //* if we fail for some reason we need to restart the 
painting
                        this.resumePainting();
                        return false;
                }
                //* get a reference to the new bitmap
                this.m_xBitmap = xTmpBitmap;
                xTmpBitmap =  null;

                //* resume the painting
                this.resumePainting();

-- 

3. How can i access the /data/data/<my_project_name>/files/my_file.txt on a real android device

4. Can't find my posts :(

5. Custom OS Build

6. Add imageview to bottom of webview

7. creating application shared libraries