Skip to content

Instantly share code, notes, and snippets.

@RohitSurwase
Created October 5, 2017 15:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save RohitSurwase/ad9880c5af9459d4f2046dc5bc277c32 to your computer and use it in GitHub Desktop.
//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