I have a "database" class that handles SQLites actions. Part of its constructor is the application's context. So far so good but now, I have a "monitor" class that extends BroadcastReceiver that needs to use this database class and I have no context to build that instance. So there are two alternatives:
Thanks
Doesn't the onReceive
method of the BroadcastReceiver
take a Context
as a parameter?
@Override
public void onReceive(Context context, Intent intent) {
MyDataBase myDb = new MyDataBase(context);
...
}
Can't you get the context
from there?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.