diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index 7b316af70..d148ba0f9 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -664,17 +664,23 @@ public class DatabaseBackend extends SQLiteOpenHelper { db.insert(RESOLVER_RESULTS_TABLENAME, null, contentValues); } - public Resolver.Result findResolverResult(String domain) { + public synchronized Resolver.Result findResolverResult(String domain) { SQLiteDatabase db = this.getReadableDatabase(); String where = Resolver.Result.DOMAIN + "=?"; String[] whereArgs = {domain}; final Cursor cursor = db.query(RESOLVER_RESULTS_TABLENAME, null, where, whereArgs, null, null, null); Resolver.Result result = null; if (cursor != null) { - if (cursor.moveToFirst()) { - result = Resolver.Result.fromCursor(cursor); + try { + if (cursor.moveToFirst()) { + result = Resolver.Result.fromCursor(cursor); + } + } catch (Exception e) { + Log.d(Config.LOGTAG, "unable to find cached resolver result in database " + e.getMessage()); + return null; + } finally { + cursor.close(); } - cursor.close(); } return result; } @@ -928,7 +934,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { final SQLiteDatabase db = this.getWritableDatabase(); db.beginTransaction(); for (Contact contact : roster.getContacts()) { - if (contact.getOption(Contact.Options.IN_ROSTER) || contact.getAvatarFilename() != null) { + if (contact.getOption(Contact.Options.IN_ROSTER) || contact.getAvatarFilename() != null || contact.getOption(Contact.Options.SYNCED_VIA_OTHER)) { db.insert(Contact.TABLENAME, null, contact.getContentValues()); } else { String where = Contact.ACCOUNT + "=? AND " + Contact.JID + "=?"; |