title: SimpleCursorAdapter throwing NullPointerException
body: <p>I found similar questions here but none of the solutions seem to work.</p>
  
  <p>This is my custom adapter's constructor.</p>
  
  <pre><code>public ContactAdapter(Context context, int layout, Cursor c, String[] from, int[] to)
      {
          super(context, layout, c, from, to, 
      }
  </code></pre>
  
  <p>This is the activity that should populate the listview.</p>
  
  <pre><code>public class ContactList extends Activity {
  
      private static final String KEY_ID = "_id";
      private static final String KEY_NAME = "name";
      private static final String KEY_PH_NO = "phone_number";
  
      public static final String[] from = new String[] { KEY_ID, KEY_NAME,
              KEY_PH_NO };
  
      public static final int[] to = new int[] { R.id.textID, R.id.nameText,
              R.id.numberText };
  
      ListView listView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_contact_list);
  
          DatabaseHandler db = new DatabaseHandler(this);
  
          Cursor cur = db.getAllContacts();
  
          ContactAdapter adapter = new ContactAdapter(this, R.layout.custom_list, cur, from, to);
  
          listView.setAdapter(adapter);
  
  
      }
  </code></pre>
  
  <p>It throws a null pointer exception. Here is my stack tree.</p>
  
  <pre><code>    08-12 11:39:17.647: E/AndroidRuntime(6902): FATAL EXCEPTION: main
      08-12 11:39:17.647: E/AndroidRuntime(6902): java.lang.RuntimeException: Unable to start activity ComponentInfo
  {com.example.databaseproject/com.example.databaseproject.ContactList}: java.lang.NullPointerException
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.os.Handler.dispatchMessage(Handler.java:99)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.os.Looper.loop(Looper.java:137)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.ActivityThread.main(ActivityThread.java:5103)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at java.lang.reflect.Method.invokeNative(Native Method)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at java.lang.reflect.Method.invoke(Method.java:525)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at dalvik.system.NativeStart.main(Native Method)
      08-12 11:39:17.647: E/AndroidRuntime(6902): Caused by: java.lang.NullPointerException
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at com.example.databaseproject.ContactList.onCreate(ContactList.java:42)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.Activity.performCreate(Activity.java:5133)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
      08-12 11:39:17.647: E/AndroidRuntime(6902):     ... 11 more
  </code></pre>
  
  <p>Please ask if any other code sample is required to trace the issue.</p>
  
  <p>PS: I checked the database that gets created. It has values(it is not empty).
  If I comment this line it doesn't throw the error.</p>
  
  <pre><code>listView.setAdapter(adapter);
  </code></pre>