Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//This class is used to write all Abstract (Insert, Query, Update, Delete) methods.
public class DatabaseQueryHandler {
private SQLiteDatabase mSqLiteDatabase;
private Context mContext;
//Default Constructor
/*Here I have created parameterised constroctor with context and isWritable as parameters. The boolean value of isWritable allows me to get readable or writable instance of SQLite Database */
public DatabaseQueryHandler(Context context, boolean isWritable) {
DatabaseHelper databaseHelper = DatabaseHelper.getInstance(context);
mContext = context;
if (isWritable) {
mSqLiteDatabase = databaseHelper.getWritableDatabase();
} else {
mSqLiteDatabase = databaseHelper.getReadableDatabase();
}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment