I have the following class that allows the user to get an object SQLiteOpenHelper
import android.content.Context;
public class DBUtils {
private DBUtils(){
}
private static DBHelper dbHelper ;
public static synchronized DBHelper getDBHelper(Context context){
if(dbHelper == null){
dbHelper = new DBHelper(context, ApplicationMetaData.DATABASE_NAME, null, ApplicationMetaData.DATABASE_VERSION);
}
return dbHelper;
}
public static synchronized void closeDBHelper(){
if(dbHelper!=null )
dbHelper.close();
dbHelper = null;
}
@Override
protected Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
}
I want to know where I should closepass this singleton object, I can not pass by the method onTerminate(), since it will not be called. I want to close it when the user exits my application? any solution for this
source
share