I would like to start a Thread that need a context since the Thread accessed database, but i don't have the Context for database instantiation
<p>i'm a newbie here and a newbie for an android developer too...<br>
And i had a problem with this :<br>
I would like to start a Thread upon the android started, so i made something like this  </p>

<pre><code>public class StartUpWelcomer extends BroadcastReceiver {

@Override
public void onReceive(Context arg0, Intent arg1) {
    // TODO Auto-generated method stub
    arg0.startService(new Intent(arg0, StartUpService.class));
}
</code></pre>

<p>With my Manifest : </p>

<pre><code>&lt;receiver android:name=".StartUpWelcomer"&gt;
        &lt;intent-filter&gt;
             &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;
    &lt;service android:enabled="true" android:name=".StartUpService" /&gt;
</code></pre>

<p>And this is my StartUpService class</p>

<pre><code>public class StartUpService extends Service {

@Override
public IBinder onBind(Intent arg0) {
    // TODO Auto-generated method stub
    return null;
}

public void onCreate()
{
    BackgroundApplication application = (BackgroundApplication)this.getApplication();
    ReminderThread reminderThread = new ReminderThread(null);
    if(!reminderThread.failed)
    {
        reminderThread.start();
        application.setRunningThread(reminderThread);
        Log.d("SERVICE", "CREATION CONFIRMED");
    }
    else
    {
        Log.d("SERVICE", "CREATION CANCELLED");
    }
}
</code></pre>

<p>And here's the code for the ReminderThread class</p>

<pre><code>public ReminderThread(Context ctx)
{
    this.ctx = ctx;
    db = new SQLdb(ctx);
//and there's some other code here that accessed the database functions
}
</code></pre>

<p>Ok, so here's my intention...<br>
I would like the StartUpWelcomer to activate the StartUpService (and it's working)<br>
StartUpService will instantiate a new Thread, activating it and keeping it accessible in my application (which is called as BackgroundApplication class)<br>
And here's the problem... The ReminderThread actually need to access database (SQLite here), so the ReminderThread instantiated the database to access it. But, my database constructor need a Context to be instantiated. I have no idea where to get the Context here (from the Service class) where i usually get it from Activity class.... (temporarily i put "null" there)
Another problem is, somehow i found that this always cause a NullPointerException...<br>
Please help...</p>
