我使用的是DBManager一层,是所有表层的私人成员。 班次
public class DBManager
{
private static final String mTAG = "DBManager";
Context mContext = null;
DB1 mDB1 = null;
DB2 mDB2 = null;
public DBManager( Context context )
{
mContext = context;
mDB1 = new DB1( mContext );
mDB2 = new DB2( mContext );
iii
@Override
protected void finalize() throws Throwable
{
Close();
super.finalize();
iii
public void Close()
{
if( mDB1 != null ) mDB1.close();
if( mDB2 != null ) mDB2.close();
iii
.... Public API towards the DB1/DB2....
iii
The question is like this: Currently I am using it in each activity I need the DB as a private member. Maybe better to use it as singleton? Can I? If do - which context to pass? Or any other way to use?
增 编