I can Access Database function from my Activity and it works fine. But when I use the same in Broadcast receiver class it fails and gives me default value of cursor ,And my logcat shows this:
close() was never explicitly called on database
DatabaseObjectNotCloseException
I have also done
db = context.openOrCreateDatabase("blitz.db", 0, null);
dh=new DataHelper(context);
and passed the context of onReceiver method to DataHelper Class.
It shows error on this line
OpenHelper openhelper=new OpenHelper(this.context);
this.db=openhelper.getWritableDatabase();
Please let me know where I am going wrong
always close the database when you finished your database work,
for simplicity create following method in your databaseHandler class ,
and use this methods in your activity or service as,
or you can open and close the database in your single mehod(which is in your database handler class) as
and call this method from your activity as,
In general,if u want to open an window of your house which is already open before then you have to close it and again open it,in the same manner if your database is already opened and if you want to open it again then you have to close it first.so that you can open it again.