2012-01-10 4 views
0

通常、このコードを使用して連絡先のvカードデータを読み取ります。アンドロイドストアの連絡先のvcardデータはどうですか?

AssetFileDescriptor afd = context.getContentResolver().openAssetFileDescriptor(
      Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey), "r"); 

ここで、vカードのデータは物理的に格納されていますか?私はcontacts2.dbを見ましたが、そこにもありません?

openAssetFileDescriptorはどのように動作するのですか?

答えて

0

Androidは必要に応じて情報を取得しますContacts APIS VCardとして内部メモリに保存されているとは思われません。 あなたがandroid.pim.vcardパッケージを通過し、さらに詳細にoutput_はOutputStreamのインスタンスであるVCardComposer.javaで 見て、VCardBuilder.java

0
AssetFileDescriptor fd = mContext.getContentResolver() 
         .openAssetFileDescriptor(uri, "r"); 

       BufferedInputStream fips = new BufferedInputStream(
         fd.createInputStream()); 
       byte[] byteOneLine = new byte[8*1024]; 
       while(fips.read(byteOneLine) != -1){ 
        output_.write(byteOneLine); 
       } 

を得ることができます。

ただし、 "mContext.getContentResolver()openAssetFileDescriptor(uri、" r ")"を実行するのに長時間かかる場合があります。 私は600の連絡先を持っているとき、20秒を費やします。

もっと良い方法をお探しですか?

0

シンプルでクリーンな方法:

詳細は、ここに私の答えをチェックしてください:answer

コード:

public ArrayList<String> getContactsAsVcards() 
{ 
    ArrayList<String> vcards = new ArrayList<String>(); 
    VCardComposer vCardComposer = new VCardComposer(context); 

    vCardComposer.init(); 

    do { 
     String vCard = vCardComposer.createOneEntry(); 

     vcards.add(vCard); 
    } while (!vCardComposer.isAfterLast()); 

    return vcards; 

} 
関連する問題