i have made a few multi activity database applications using sqlite,
but i get error messages in logcat like
Finalizing a Cursor that has not been deactivated or closed
or database not closed error
my apps seems to run fine.
i tried to close cursor and database using the onDestroy or after query or on changing activity,
but then either the application crashes or i get null pointer exception or an empty listview.
i would like to know what problems i can face if i just leave things as it is,
like database corruption or interfrence with other applications.
also i want to know if suppose i declare cursor
protected Cursor a_cursor;
in 1st activity, do i need to use the same declaration in the next activity
or do i need to use
protected Cursor b_cursor;
similarly for DbHelper,Context,Sqlitedatabase etc in 1st activity like
private SQLiteDatabase adb;
private DatabaseHelper aDbHelper;
private final Context aCtx;
to
private SQLiteDatabase bdb;
private DatabaseHelper bDbHelper;
private final Context bCtx;
in 2nd activity
the structure of the program is like this
DatabaseHelper — to create some tables or upgrade
DbAdapter — to insert or update tables
Activity1 — search a table and listview — on list itemclick –Activity2 ,
context menu to add some details to 2nd table
Activity2 — item details and button for Activity3
Activity3 — Edit item — return
Activity4 — 2nd table listview
Activity5 — Database import export
sorry if my question seems too ametuerish or primitive
but i am not a programmer and the apps are for my personal use
not intended for the market
actually i did not find a complete example to suit my needs
so i just added bits and peices from many examples to get things done
It used to be that we’d say to use managedQuery to deal with this stuff. But since the CursorLoader was added, I suggest using that to keep everything straight. The cursor loader wasn’t added until API Level-10, but you can still use it on lesser API levels through the Support Package.
For an example of using a CursorLoader, you can checkout this Example (or the corresponding full-fledged example.)