Made Database Helper object static for permanent connection.

This commit is contained in:
Pierre 2017-12-29 12:48:48 +01:00
parent 491e75e814
commit 7dc2fabcd3

View File

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