我有以下类允许用户获取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 {
// TODO Auto-generated method stub
throw new CloneNotSupportedException();
}
}
我想知道这个单例对象应该在哪里,因为它不会被调用,所以close
我无法在该方法上进行中继。onTerminate()
我想在用户退出我的应用程序时关闭它?任何解决方案