In some passages, I had the error of sqllite "open connection already open" ... ok, actually I was not busy to always close the connection since I had read that it was advisable not to do it if the operations were not massive ... but obviously it is not always true ... or not? I am confused at this point ....
To solve this problem I inserted this code in every activity that does database operations with its adapter:
@Override
protected void onDestroy ()
{
super.onDestroy ();
mDbHelper.closeConnection ();
}
This has solved everything and everything has worked for months.
Now implementing other I receive this error:
"attempt to reopen already closed object then database closed"
An 'Activity calls via OnActivityForResult another activity but "someone or something" (I assume low-level android) calls my "OnDestroy" (going to close the connection) ... the reason that triggers the error I have found but I have no idea how to intervene ... I'm not the one to call OnDestroy but Android ... how does it come out?
For now (in my case of the activity that calls the other) I have circumvented the problem like this:
@Override
protected void onDestroy ()
{
if (! m_Modality.equalsIgnoreCase ("MYCALLBACK"))
{
mDbHelper.closeConnection ();
}
}
But I do not like it and I would like to understand once and for all how the hell you have to work on this sqlite ...
If I do not have to close the connection because of messages about whether it is already open?
If I close it because then by messages saying that it has just been closed?
If ANDROID call the methods where I insert the closure of the connection as I can never manage things in a definitive way?
I hope someone can clarify my ideas ...