android - export contacts from listview of my application -
I just want to copy the contacts Czech on the SD card as a vcf file
items selected = "Selected items: \ n"; (Int i = 0; i & lt; lstContacts.getCount (); i ++) {view = lstContacts.getChildAt (i); Check = (checkbox) view.findViewById (R.id.cb2); If (check.isChecked ()) {itemsSelected + = lstContacts.getItemAtPosition (i) + "\ n"; }}
Finally I got an answer to this question. In this, lv listview has a contact list just copy this code and you can see the contacts that you want to copy the SD card.
long [id] = lv.getCheckedItemIds (); (Long id: id) {cursor phone = receptive (). Query (or exposure. For Comndetaind. Phone. Contransurai, blank, ContactContact. Comndetakindkpon. Contaksadiaidi + "=?", New string [] {id + "}}, null); phones.moveToFirst (); (Int i = 0; i & lt; phones.getCount (); i ++) {string Lukapake = Fonskgetstring (Fonkget column index (Snprkkaktraktkcontekt. LOOKUP_KEY)); Uri Uri = Uri. Sathapekshit post ( ContactContact.com contacts.contENT_VCARD_URI, look up;); Ti file descriptor fd; Try {fd = this.getContentResolver (). OpenAssetFileDescriptor (Yuri, "r"); Fis = fd.createInstreamStream (); byte [] buf = new byte [(int) fd.getDeclaredLength ()]; fis.read (buf); string vCard = new string (buf); // Personal file mPath = new file (Environment.getExternalStorageDirectory () + "// yourdir //"); SdCard = new file (environment .getExternalStorageDirectory () + "// yourdir //"); Directory = new file (sdCard.getAbsolutePath ()); directory.mkdirs (); file = new file (directory, vfile); // string path = Pryavarnkgetaksanlstorej directory (). ToString () + File Separator + vfile; FileOutputStream mFileOutputStream = New FileOutputStream (file, true); MFileOutputStream.write (vCard.toString () getBytes ().); Phones.moveToNext (); // Log D. ("Vicard", Vicard); } Grip (Exception E1) {// TODO Auto-Generated Cache Block e1.printStackTrace (); }}} Toast.makeText (this, "copy of contacts" + vfile, toast.LENGTH_SHORT). Show ();
Comments
Post a Comment