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; } /**