package ai.pai.lensman.db;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;


public class DBService {

    private static DBService instance;
    private static Object DB_LOCK = new Object();
    private DBHelper dbHelper;

    private static final String TAG = "czy";

    private DBService(Context context) {
        dbHelper = DBHelper.getInstance(context);
    }

    public static synchronized DBService getInstance(Context context) {
        if (instance == null) {
            instance = new DBService(context.getApplicationContext());
        }
        return instance;
    }

    private void closeDB(SQLiteDatabase db) {
        if (db != null) {
            db.close();
        }
    }

    private void closeCursorAndDB(Cursor cursor, SQLiteDatabase db) {
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
        if (db != null) {
            db.close();
        }
    }

}
