aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-16 00:34:16 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-16 00:34:16 +0100
commitac4eabbd2257217eebddfc33840a618e78a97cad (patch)
treefc3be7cbbd357befca2dae6f75f532612d99010b /src/main
parent17c2ed411d747f3206e0e4ea4cd7c4e8331f7d11 (diff)
close cursor for database
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
index ef045546..e5ea8f90 100644
--- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -143,7 +143,9 @@ public class DatabaseBackend extends SQLiteOpenHelper {
+ Conversation.TABLENAME + " where " + Conversation.STATUS
+ "=" + Conversation.STATUS_AVAILABLE, null);
cursor.moveToFirst();
- return cursor.getInt(0);
+ int count = cursor.getInt(0);
+ cursor.close();
+ return count;
}
public CopyOnWriteArrayList<Conversation> getConversations(int status) {
@@ -156,6 +158,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
while (cursor.moveToNext()) {
list.add(Conversation.fromCursor(cursor));
}
+ cursor.close();
return list;
}
@@ -189,6 +192,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
list.add(message);
} while (cursor.moveToPrevious());
}
+ cursor.close();
return list;
}
@@ -201,7 +205,9 @@ public class DatabaseBackend extends SQLiteOpenHelper {
if (cursor.getCount() == 0)
return null;
cursor.moveToFirst();
- return Conversation.fromCursor(cursor);
+ Conversation conversation = Conversation.fromCursor(cursor);
+ cursor.close();
+ return conversation;
}
public void updateConversation(Conversation conversation) {
@@ -313,7 +319,9 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return null;
}
cursor.moveToFirst();
- return Conversation.fromCursor(cursor);
+ Conversation conversation = Conversation.fromCursor(cursor);
+ cursor.close();
+ return conversation;
}
public Message findMessageByUuid(String messageUuid) {
@@ -325,7 +333,9 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return null;
}
cursor.moveToFirst();
- return Message.fromCursor(cursor);
+ Message message = Message.fromCursor(cursor);
+ cursor.close();
+ return message;
}
public Account findAccountByUuid(String accountUuid) {
@@ -337,7 +347,9 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return null;
}
cursor.moveToFirst();
- return Account.fromCursor(cursor);
+ Account account = Account.fromCursor(cursor);
+ cursor.close();
+ return account;
}
public List<Message> getImageMessages(Conversation conversation) {
@@ -355,6 +367,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
list.add(message);
} while (cursor.moveToPrevious());
}
+ cursor.close();
return list;
}
}