aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java b/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
index e721afbb..fd227e5a 100644
--- a/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
+++ b/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
@@ -58,7 +58,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "history";
private static final int DATABASE_VERSION = 25;
private static final int C_TO_CPLUS_VERSION_OFFSET = 1000;
- private static final int CPLUS_DATABASE_VERSION = 3;
+ private static final int CPLUS_DATABASE_VERSION = 5;
private static final int CPLUS_DATABASE_VERSION_MULTIPLIER = 100;
private static final int PHYSICAL_DATABASE_VERSION = DATABASE_VERSION + C_TO_CPLUS_VERSION_OFFSET + (CPLUS_DATABASE_VERSION * CPLUS_DATABASE_VERSION_MULTIPLIER);
@@ -217,7 +217,8 @@ public class DatabaseBackend extends SQLiteOpenHelper {
cursor.close();
}
- if (oldVersion < 3 && newVersion >= 3) {
+ if ((oldVersion < 3 && newVersion >= 3)
+ || (oldVersion <= 5 && newVersion >= 4)) {
MessageDatabaseAccess.upgrade(db, oldVersion, newVersion);
}
}
@@ -719,25 +720,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
public Pair<Long, String> getLastMessageReceived(Account account) {
- Cursor cursor = null;
- try {
- SQLiteDatabase db = this.getReadableDatabase();
- String sql = "select messages.timeSent,messages.serverMsgId from accounts join conversations on accounts.uuid=conversations.accountUuid join messages on conversations.uuid=messages.conversationUuid where accounts.uuid=? and (messages.status=0 or messages.carbon=1 or messages.serverMsgId not null) order by messages.timesent desc limit 1";
- String[] args = {account.getUuid()};
- cursor = db.rawQuery(sql, args);
- if (cursor.getCount() == 0) {
- return null;
- } else {
- cursor.moveToFirst();
- return new Pair<>(cursor.getLong(0), cursor.getString(1));
- }
- } catch (Exception e) {
- return null;
- } finally {
- if (cursor != null) {
- cursor.close();
- }
- }
+ return MessageDatabaseAccess.getLastMessageReceived(this.getReadableDatabase(), account.getUuid());
}
private Cursor getCursorForSession(Account account, AxolotlAddress contact) {