• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Sqlite Database context android

Bhavin392

Lurker
Oct 14, 2019
2
0
I have created a Database class file to use SQLite db in Android app. Since I am beginner and I am having problem understanding what should i put in context when I instantiate Database class to another class The database code is as follows:
public Database(@nullable Context context) {
super(context,DATABASE_NAME,null,DATABASE_VERSION);
database=getWritableDatabase();
How can I instantiate it to an another class. When doing instantiation Database db = new Database(); what should be put under context
 
I have created a Database class file to use SQLite db in Android app. Since I am beginner and I am having problem understanding what should i put in context when I instantiate Database class to another class The database code is as follows:
public Database(@nullable Context context) {
super(context,DATABASE_NAME,null,DATABASE_VERSION);
database=getWritableDatabase();
How can I instantiate it to an another class. When doing instantiation Database db = new Database(); what should be put under context
Database db =new Database(Combiner.this);. I tried this but its showing Database(android.content,Context) in Database cannot be applied to (com.example.data.Combiner)
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones