Sunday, February 20, 2011

SQLiteDatabase created and never closed

Problem
When I'm using my application and I can see this error in the LogCat tab :


02-17 17:20:38.556: ERROR/Database(434): Leak found
02-17 17:20:38.556: ERROR/Database(434): java.lang.IllegalStateException: /data/data/databases/xx.db SQLiteDatabase created and never closed


Solution
Well, at first I thought it was because of my cursors. So I decided to check every cursor and close them all after having done with them.
But I still got the same problem.

So in fact, it's just that for every activity (onCreate) I was opening a connection to the database, but I never closed it.
So the solution was to close the connection in each activity:


@Override
protected void onStop() {
dbService.closeConnection();
super.onStop();
}


And that's it !

Sunday, February 13, 2011

Android Insufficient storage

Problem
I was debugging my application using an android virtual device in Eclipse.
When I run the application I could see this error in the console:

[2011-02-12 19:22:25 - shiro] Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
[2011-02-12 19:22:25 - shiro] Please check logcat output for more details.
[2011-02-12 19:22:25 - shiro] Launch canceled!

The size of my app is around 22Mo (there are a lot of pictures).

Solution
The first time I configured the android virtual device, I put only 2 or 3Mo for "SD Card size".
So I had no choice to create a new virtual device and put something like 30Mo.
I ran my app for the first time. No problem. Then I wanted to run it again, and I got the same problem. I guess I could set the size of SD card to 100Mo, or in the virtual device, you can go to the menu > settings > manage applications. Then choose the application and uninstall it. Then you can run your app again in debug mode from Eclipse.

And that's it!