Simple answer: if you are implementing a component like Activity, Service,
and ContentProvider, don't implement a constructor.  (That is just use the
default empty constructor).  Whatever you think you want to do in the
constructor...  you very like don't, and should do in onCreate() instead.

On Wed, Aug 11, 2010 at 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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

Reply via email to