Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old May 16th, 2009, 09:06 AM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Costa's Avatar
 
Join Date: Apr 2009
Location: Portugal
Posts: 30
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Contact list

Hello guys.


I wanted import the contacts and all their data associated (adress, phone number, etc) to my application.

Do you guys have any example of code how to do it?

Cheers!

Costa is offline  
Reply With Quote
sponsored links
Old May 17th, 2009, 10:34 AM   #2 (permalink)
Junior Member
Thread Author (OP)
 
Costa's Avatar
 
Join Date: Apr 2009
Location: Portugal
Posts: 30
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anyway, i made it.

ContactList.java
Code:
public class ContactList extends Activity {
        
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.contactlist);
        
        final Cursor c = managedQuery(People.CONTENT_URI, null, null, null, null);
        String[] from = new String[] {People.NAME};
        int[] to = new int[] { R.id.text_view };
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.contactlist,c,from,to);
        ListView lv = (ListView)findViewById(R.id.list_view);
        lv.setAdapter(adapter);
    }
}
contactlist.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
    <ListView
    android:id="@+id/list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
    <TextView
    android:id="@+id/text_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
</LinearLayout>
Hope helps someone in future
Costa is offline  
Reply With Quote
Old June 4th, 2009, 10:39 AM   #3 (permalink)
New Member
 
Join Date: May 2009
Posts: 7
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

Is this code working? Its saying "R.layout.contactlist cannot be resolved" and when I copied the xml to main.xml its saying "No grammer constraints detected for this document". Please tell me how to solve this matter.
randheer is offline  
Reply With Quote
Old May 13th, 2010, 01:33 AM   #4 (permalink)
New Member
 
Join Date: May 2010
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

import android.R;
lucienmathieu is offline  
Reply With Quote
Old June 2nd, 2010, 06:56 AM   #5 (permalink)
New Member
 
Join Date: Jun 2010
Posts: 14
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

This contact article will help u...

Mobile - Articles, News, Discussions, Samples: Android contacts article - Display, Addition, Deletion and updation
ganeshpisal is offline  
Reply With Quote
Old June 5th, 2011, 12:58 AM   #6 (permalink)
Member
 
Join Date: Jan 2010
Posts: 116
 
Device(s): Moto Droid Samsung Charge
Carrier: Not Provided

Thanks: 1
Thanked 7 Times in 7 Posts
Default

How would you extract phone numbers, names, or addresses using this code?
cmh0114 is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:01 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.