Sunday, November 28, 2010

[android-developers] Re: Import Contacts from .vcf file in Android 2.1

Thanks Jens for the reply.

I am afraid why Android has kept the import contacts api hidden though
to export contacts in vcf format is available.

I think I have to go hard way by packaging android source code in the
app until I find a better solution for this.

Thanks,
Prateek


On Nov 28, 8:03 pm, Jens <dunkingbikk...@gmail.com> wrote:
> Afaik there is no "standard" way to insert contacts from a vcf file
> into the contacts provider. The entire package that deals with vCards,
> android.pim.vcard is hidden in the SDK and not available unless you're
> a big fan of abusing Java Reflection - in short, you should lift the
> parser from the android source tree and package it in your app.
>
> If you want to browse the code it uses for serializing and parsing
> vCards (both 2.1 and 3.0) it's available here.http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/java/androi...
>
> On 26 Nov, 06:11, Prateek Jain <mrprateekj...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > I am able to retrieve all contacts from android in .vcf file using
> > following code.
>
> > ContentResolver cr = getContentResolver();
> >     Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null,
> > null, null, null);
> > String lookupKey =
> > cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
> >                         Uri uri =
> > Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI,
> > lookupKey);
> >                         System.out.println("The value is " +
> > cr.getType(uri));
> >                         AssetFileDescriptor fd =
> > this.getContentResolver().openAssetFileDescriptor(uri, "r");
> >                         FileInputStream fis = fd.createInputStream();
>
> > I don't know how to use this .vcf file to import all these contacts
> > using code. The .vcf file contains all the details of all contacts
> > including photos etc.
>
> > Cheers, Prateek

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate