I think the problem is that you need to close the db when your activity is destroyed. Try adding this to your activity:
@Override
protected void onDestroy() {
super.onDestroy();
if (openHelper != null) {
openHelper.close();
}
if (cdh != null) {
cdh.close();
}
}
and add this to your CallDataHelper class:
public void close() {
// NOTE: openHelper must now be a member of CallDataHelper;
// you currently have it as a local in your constructor
if (openHelper != null) {
openHelper.close();
}
}
EDIT 2: Also change the CallDataHelper constructor to:
// Declare openHelper as a member variable
OpenHelper openHelper = null;
public CallDataHelper(Context context) {
this.context = context;
openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
}
This should successfully close the database connection that was created by both of your OpenHelper
instances.
( EDITED to reflect the fact that you use two OpenHelper instances.)