s contatos agregados são adicionados automaticament
você deve ter visto esse pedaço de código em outro lugar também, mas obviamente não há resposta para essa exceçã
EDIT: Se você veio aqui para encontrar uma solução para restaurar contatos via vcardio. É isso !!
Eu peguei isso enquanto utilizava o vCardIO api para android usado para restaurar contatos do vcard para os contatos db. Eu tenho usado o seguinte método doImport () que deveria funcionar muito bem, mas não
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();
}