mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 15:59:29 +00:00
Made Database Helper object static for permanent connection.
This commit is contained in:
parent
491e75e814
commit
7dc2fabcd3
@ -94,6 +94,11 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
ConversationsMessagesSchema.TABLE_NAME;
|
ConversationsMessagesSchema.TABLE_NAME;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object cached instance
|
||||||
|
*/
|
||||||
|
private static DatabaseHelper instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current database helper instance
|
* Get the current database helper instance
|
||||||
*
|
*
|
||||||
@ -101,7 +106,10 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
* @return DatabaseHelper object
|
* @return DatabaseHelper object
|
||||||
*/
|
*/
|
||||||
public static synchronized DatabaseHelper getInstance(Context context){
|
public static synchronized DatabaseHelper getInstance(Context context){
|
||||||
return new DatabaseHelper(context.getApplicationContext());
|
if(instance == null)
|
||||||
|
instance = new DatabaseHelper(context.getApplicationContext());
|
||||||
|
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user