Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Filesystemerror(12) and Database is null or closed when opening App

Hi All,

           I am facing a problem when working with thread + Database conecpt based App.

 

            When I am opening app, sometimes it is not able to access the database and treat as there is no database available in the SD card. This issue is not generated at the first launch of App. It is generated at the 3 or 4th launch of App.

For this, I thought that when I am closing App, it doesn't close database connection and when launching App, it shows 'Filesystemerror(12)' or 'Database is null or closed' error and not fetching any data from database.

It is repeating again and again when launching the App. When I restart the BlackBerry, it works fine.

Because any opened database connection has been closed after restart of device.

 

Please tell me how can I close all DB connections and sqlite Connection at the closing time of App. Please give any solution for it and ask me, if you didn't get the problem.

Developer
Posts: 19,628
Registered: ‎07-14-2008
My Device: Not Specified

Re: Filesystemerror(12) and Database is null or closed when opening App

Maybe I am being stupid here, but it seems to me that you open the SQL database, so you can close it?  You just need to keep a record that you have opened it.  So can you not create some sort of 'Singleton' that records database open, and then use it to close the database?

 

AFAIK, there is no single place you can put a 'hook' into that will catch all invocations of System.exit().  So I would recommend that you don't do that everywhere.  Instead place the System,exit() is one shared place, say MyApp.exit().  Then in all the other places that you want to exit the application invoke MyApp.exit() in place of System.exit().  Then in the shared method you can tidy up anything you need to, including the open SQL database. 

 

One other option is to use deactivate, as described here:

http://supportforums.blackberry.com/t5/Java-Development/File-System-error-12/m-p/630204#M130886

 

The problem with this approach is that deactivate is called when the app is put in the background and when you exit the application.  You might not want the database closed just because the user got a phone call...

 

If you search for "Error 12" you will find other potentially useful Threads including this one:

 

http://supportforums.blackberry.com/t5/Java-Development/DatabaseIOException-File-system-error-12-whe...