Calling a database class from an intent
<p>I'm wondering how I make a call to my db class from an intent that I have created. When I make a call in the intent class, I get a null pointer exception, its like the intent can't see the external class.... any ideas greatly appreciated or pointers to links ?</p>

<p>call for intent from the mail class</p>

<pre><code>Intent showContent = new Intent(context, IntentResults.class);
Log.d(LOG_TAG, "About to launch sub-activity");

// Set the request code to any code you like, you can identify the
// callback via this code
startActivityForResult(showContent, 0);
Log.d(LOG_TAG, "launched sub-activity");
</code></pre>

<p>Then I call the intent class will the db class included.
    AABDatabaseManager db = new AABDatabaseManager(this);
    public class IntentResults extends Activity{</p>

<pre><code>    private static final String LOG_TAG = "IntentResultsClass";

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.intentayanlsisdatapage);

    Log.d(LOG_TAG, "in sub-activity");




    Log.d(LOG_TAG, "finish should have run");

    int NumOfEntries = db.countNumberOfEntries();

    String numberOfEntries = ""+NumOfEntries;
</code></pre>

<p>I get a null pointer here on </p>

<pre><code>int NumOfEntries = db.countNumberOfEntries() 
</code></pre>

<p>as the db class doesent seem to be carried through. I have been looking at:</p>

<p><a href="http://stackoverflow.com/questions/3347247/external-asynctask-class-with-progressdialog-update-and-returning-back">External AsyncTask class with ProgressDialog [Update: and returning back?]</a></p>

<p>but no joy on figureing out why when I call the db class from the intent it doesnt want to work for me, any help greatly appriceated.</p>

<p>Just to add more detail:</p>

<pre><code>11-30 12:42:09.199: WARN/dalvikvm(31304): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304): FATAL EXCEPTION: main
11-30 12:42:09.311: ERROR/AndroidRuntime(31304): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test3.patrickrice.net/test3.patrickrice.net.IntentResults}: java.lang.NullPointerException
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.os.Looper.loop(Looper.java:123)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at java.lang.reflect.Method.invokeNative(Native Method)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at java.lang.reflect.Method.invoke(Method.java:521)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at dalvik.system.NativeStart.main(Native Method)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304): Caused by: java.lang.NullPointerException
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at test3.patrickrice.net.AABDatabaseManager.&lt;init&gt;(AABDatabaseManager.java:65)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at test3.patrickrice.net.IntentResults.&lt;init&gt;(IntentResults.java:17)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at java.lang.Class.newInstanceImpl(Native Method)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at java.lang.Class.newInstance(Class.java:1429)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
11-30 12:42:09.311: ERROR/AndroidRuntime(31304):     ... 11 more
11-30 12:42:09.389: WARN/ActivityManager(59):   Force finishing activity test3.patrickrice.net/.IntentResults
11-30 12:42:09.889: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{45147568 test3.patrickrice.net/.IntentResults}
11-30 12:42:19.395: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
</code></pre>

<p>Thanks
Pat</p>
