The simple solution, that followed by all (at least, all of it that I have seen) Google's sample and tutorial code is: don't use the constructor. Do all your initialization instead in onCreate().
If you do this, the problem you are having goes away. You should almost certainly be using a (built-in?) ContentProvider for the SQL anyway. This will manage the lifecycle for you, if you use a managed Cursor to access the database. Then you don't have to pull a database from the resources and copy it. The system will open it when needed and return database resources to the pool when no longer needed On Aug 11, 1:10 am, Scott Herbert <[email protected]> wrote: > Firstly I hope this isn't too basic a question, I'm new to Java (and > be extension Android) so please forgive me if it's obvious to everyone > else, but I couldn't find the answer via Google. > > I have a simple app I'm writing primary because I and at least one of > my friends want it but also to learn Java. Part of this application > pulls a database from the resources and copy's it so it can be > accessed via SQLite, and I use a class that extends SQLiteOpenHelper > to copy the database. > > And here lies the problem, as soon as this class exists (the > constructor is called) I get a runtime exception, comment it out it > runs fine. > > I think this is because the constructor is setting a String (db_path) > that is used by onCreate, and so if onCreate is fired before the > constructor it tries to use db_path and fails because it's not set. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

