you must have seen this piece of code somewhere else too,but obviously there's no answer for this exception.
EDIT: IF You've come here finding a solution to restoring contacts via vcardio.This is IT!!
I got this while utilising the vCardIO api for android used to restore contacts from vcard to the contacts db.I have been using the following doImport() method which is supposed to work just fine,but it isnt!
public void doImport(final String fileName, final boolean replace) {
try {
File vcfFile = new File(fileName);
final BufferedReader vcfBuffer = new BufferedReader(new FileReader(fileName),1048576);
final long maxlen = vcfFile.length();
// Start lengthy operation in a background thread
long importStatus = 0;
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
SQLiteStatement querySyncId = db.compileStatement("SELECT " + SYNCID + " FROM " + SYNCDATA_TABLE_NAME + " WHERE " + PERSONID + "=?");
SQLiteStatement queryPersonId = db.compileStatement("SELECT " + PERSONID + " FROM " + SYNCDATA_TABLE_NAME + " WHERE " + SYNCID + "=?");
SQLiteStatement insertSyncId = db.compileStatement("INSERT INTO " + SYNCDATA_TABLE_NAME + " (" + PERSONID + "," + SYNCID + ") VALUES (?,?)");
db.close();
Contact parseContact = new Contact(querySyncId, queryPersonId, insertSyncId);
String popa="";
popa=parseContact.getContent();
try {
long ret = 0;
do {
ret = parseContact.parseVCard(vcfBuffer);
//this is the snippet line which has the potential to beat the blues out of any programmer,always throwing an exception!
parseContact.addContact(CO, 0, true);
} while (ret > 0);
db.close();
} catch (Exception e) {
Toast.makeText(CO,"NO "+e.getMessage()+"-"+e.getLocalizedMessage()+"-"+e.toString(), Toast.LENGTH_SHORT).show();
}
Thanks,but no thanks.I managed it myself,Alhumdulillah.Make the following changes to
doImport();
Method of VCardIO: