0

I have developed a tab-based application using API level 7. It is running fine with Android 2.1 device. But it is giving problem when I am trying to run it in 2.2 device. When I visit any tab first time, it is OK. But if the same tab is revisited, it is giving following error msg.

android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here

But no such problem in 2.1 device. Here I like to mention that I have closed the database connection in each of the activity of any tab.

More surprisingly, initially I am at tab A. For Tab A I have done some database operation. Then I go to tab B with no problem where also database operation is done with same database. Then if I come back to tab A, it is giving this error. If it is database and cursor closing related problem, it should give exception when I am going from tab A to B. Can anyone locate where is problem?

rekire
  • 47,260
  • 30
  • 167
  • 264
dev_android
  • 8,698
  • 22
  • 91
  • 148
  • Are you sure you are closing all cursors? Cursors that are used inside an Activity can be closed automatically, just call startManagingCursor(Cursor) everytime you return a cursor from the database. Do a null check before (otherwise you get an exception when exiting the activity). – Daniel Novak Jun 28 '11 at 12:32
  • I have used cursor close after every cursor operation or used call startManagingCursor(Cursor). Moreover cursor closing problem should rise in 2.1 also. But in my case there is no problem in 2.1. It is giving prob only in 2.2. – dev_android Jun 28 '11 at 12:56
  • Yes, that's strange that it happens only in 2.2. Are you also sure that you are not openning the database connection twice (and not closing it before)? EDIT: I see that you are closing the connection. – Daniel Novak Jun 28 '11 at 12:58

1 Answers1

0

It is not at all tab related prob. In onCreate() there is a code-

datePickerDialog = new DatePickerDialog(getParent(), ButtonTestDateListener,
                mYear, mMonth, mDay);

I have just declare the mYear, mMonth and mDay as Integer, but no initialization was there. It is working fine in 2.1, but giving prob in 2.2. Before that I have opened the database connection and not closed it. Thats why it is giving such problem.

dev_android
  • 8,698
  • 22
  • 91
  • 148