title: Multiple packages in android project
body: <p>Have a look at my AndroidMenifest.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.myapp"
          android:versionCode="1"
          android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="16" /&gt;
  
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" &gt;
      &lt;/uses-permission&gt;
  
      &lt;application
          android:allowBackup="true"
          android:debuggable="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity      android:name="com.myapp.activities.exercisesetsactivity.ExercisesetsActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"/&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.myapp.activities.mainactivity.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;!--intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter--&gt;
          &lt;/activity&gt;
  
          &lt;service
              android:name="com.myapp.services.guideservice.GuideService"
              android:exported="false" &gt;
          &lt;/service&gt;
      &lt;/application&gt;
      &lt;/manifest&gt;
  </code></pre>
  
  <p>Initially, I had MainActivity was my default activity. Later I tried to change it to ExercisesetsActivity. That is where I started getting below error in my logcat.</p>
  
  <pre><code> &gt; 
      01-22 22:09:51.831: E/AndroidRuntime(22676): FATAL EXCEPTION: main
          01-22 22:09:51.831: E/AndroidRuntime(22676): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.activities.exercisesetsactivity.ExercisesetsActivity}: java.lang.NullPointerException
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.os.Handler.dispatchMessage(Handler.java:99)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.os.Looper.loop(Looper.java:137)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.ActivityThread.main(ActivityThread.java:4745)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at java.lang.reflect.Method.invokeNative(Native Method)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at java.lang.reflect.Method.invoke(Method.java:511)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at dalvik.system.NativeStart.main(Native Method)
          01-22 22:09:51.831: E/AndroidRuntime(22676): Caused by: java.lang.NullPointerException
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:101)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at com.myapp.activities.exercisesetsactivity.ExercisesetsActivity.&lt;init&gt;(ExercisesetsActivity.java:24)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at java.lang.Class.newInstanceImpl(Native Method)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at java.lang.Class.newInstance(Class.java:1319)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
          01-22 22:09:51.831: E/AndroidRuntime(22676):    ... 11 more
  </code></pre>
  
  <p>If I change it to MainActivity, it works fine. However, I want ExercisesetsActivity to come up first.</p>
  
  <pre><code>package com.myapp.activities.exercisesetsactivity;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  import com.myapp.R;
  import com.myapp.activities.mainactivity.MainActivity;
  import com.myapp.businessclasses.Exercisesetlist;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.Environment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class ExercisesetsActivity extends Activity {
  **private Exercisesetlist myExerciseSetList = new Exercisesetlist(this.getApplicationContext());**
  
  private class currentListAdapter extends ArrayAdapter&lt;String&gt; {
  
      public currentListAdapter() {
          super(ExercisesetsActivity.this, R.layout.activity_exercisesetlist,
                  ExercisesetsActivity.this.myExerciseSetList.setNames);
          // TODO Auto-generated constructor stub
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          LayoutInflater inflater = getLayoutInflater();
  
          View row = inflater.inflate(R.layout.activity_exercisesetlist, parent,
                  false);
          TextView label = (TextView) row.findViewById(R.id.tvItems);
  
          String strContent = ExercisesetsActivity.this.myExerciseSetList.setNames
                  .get(position);
          label.setText(strContent);
          label.setTag(position);
          label.setOnClickListener(exerciseClickListner);
  
          return row;
      }
  
  }
  
  private android.view.View.OnClickListener exerciseClickListner = new android.view.View.OnClickListener() {
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          int pos = (Integer) v.getTag();
  
          Intent intent = new Intent(ExercisesetsActivity.this.getApplicationContext(),
                  MainActivity.class);
          intent.putExtra(ExercisesetsActivity.this.getResources().getString(R.string.EXERCISESETID),
                  ExercisesetsActivity.this.myExerciseSetList.setIDs.get(pos));
          startActivity(intent);
      }
  };
  
  // This is temporary
  public void copyDBifnotexists() {
      String DATABASE_PATH = Environment.getExternalStorageDirectory()
              .getPath() + "/myapp/data/";
      String DATABSE_NAME = "db.db";
  
      File folders = new File(DATABASE_PATH);
      File file = new File(folders, DATABSE_NAME);
      if (!file.exists()) {
          folders.mkdirs();
  
          try {
              InputStream inputStream = this.getResources().openRawResource(
                      R.raw.db);
              FileOutputStream fileOutputStream = new FileOutputStream(file);
  
              byte buf[] = new byte[1024];
              int len;
              while ((len = inputStream.read(buf)) &gt; 0) {
                  fileOutputStream.write(buf, 0, len);
              }
  
              fileOutputStream.close();
              inputStream.close();
          } catch (IOException e1) {
              e1.printStackTrace();
          }
      }
  }
  
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      // TODO Auto-generated method stub
      setContentView(R.layout.activity_exercisesetlist);
  
      // This is temporary
      copyDBifnotexists();
  
      ListView lv = (ListView) findViewById(R.id.lvExerciselist);
      lv.setAdapter(new currentListAdapter());
  }
  }
  </code></pre>