From 7dc2fabcd300cb7c660eb91f411707e18398229d Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 29 Dec 2017 12:48:48 +0100 Subject: [PATCH] Made Database Helper object static for permanent connection. --- .../android/comunic/client/data/DatabaseHelper.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/DatabaseHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/DatabaseHelper.java index 0e3e2b5..e608219 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/DatabaseHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/DatabaseHelper.java @@ -94,6 +94,11 @@ public class DatabaseHelper extends SQLiteOpenHelper { ConversationsMessagesSchema.TABLE_NAME; + /** + * This object cached instance + */ + private static DatabaseHelper instance; + /** * Get the current database helper instance * @@ -101,7 +106,10 @@ public class DatabaseHelper extends SQLiteOpenHelper { * @return DatabaseHelper object */ public static synchronized DatabaseHelper getInstance(Context context){ - return new DatabaseHelper(context.getApplicationContext()); + if(instance == null) + instance = new DatabaseHelper(context.getApplicationContext()); + + return instance; } /**