title: java.lang.RuntimeException: Unable to start activity ComponentInfo {...}: java.lang.NullPointerException
body: <p>when you click to go from one activity to another, I have an error:</p>
  
  <p><code>java.lang.RuntimeException: Unable to start activity ComponentInfo {...}: java.lang.NullPointerException</code></p>
  
  <p>I am missing some method? Please help me to understand what I did wrong, which is why you see this error?</p>
  
  <p>My activity: Zaselenie.java</p>
  
  <pre><code>import java.util.ArrayList;
  
  import android.app.Activity;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.ArrayAdapter;
  import android.widget.Spinner;
  
  public class Zaselenie extends Activity {
  
      ContactDBmoy cqh;
      KvartDB kdb;
      SQLiteDatabase sdb;
  
      private Long rowId;
  
      Spinner spZaselenie;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.zaselenie);
  
      spZaselenie  = (Spinner)findViewById(R.id.spZaselenie);
  
      // Инициализируем наш класс-обёртку
              cqh = new ContactDBmoy(Zaselenie.this);
              kdb = new KvartDB(Zaselenie.this);
  
              // База нам нужна для записи и чтения
              sdb = cqh.getWritableDatabase();
              sdb = kdb.getWritableDatabase();
  
              Bundle extras = getIntent().getExtras();
              rowId = extras.getLong(ContactMain.rowId);
  
  
  
              Cursor cursorKvart = sdb.query(KvartDB.TABLE_NAME, new String[] {
                      KvartDB._ID, KvartDB.NAME_COLUMN }, null, // The
                                                                      // columns
                                                                      // for the
                                                                      // WHERE
                                                                      // clause
                      null, // The values for the WHERE clause
                      null, // don't group the rows
                      null, // don't filter by row groups
                      null // The sort order
                      );
  
  
              ArrayList&lt;String&gt; labels = new ArrayList&lt;String&gt;();
              while (cursorKvart.moveToNext()) {
                  // GET COLUMN INDICES + VALUES OF THOSE COLUMNS
                  int idKvart = cursorKvart.getInt(cursorKvart.getColumnIndex(KvartDB._ID));
                  String nameKvart = cursorKvart.getString(cursorKvart.getColumnIndex(KvartDB.NAME_COLUMN));
                  Log.i("LOG_TAG", "ROW " + idKvart + " HAS NAME " + nameKvart);
  
  
  
                      labels.add(nameKvart);
                      // Creating adapter for spinner
                      ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this,
                              android.R.layout.simple_spinner_item, labels);
  
                      // Drop down layout style - list view with radio button
                      dataAdapter
                              .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                      dataAdapter.notifyDataSetChanged();
  
                      // attaching data adapter to spinner
                      spZaselenie.setAdapter(dataAdapter);
              }
              cursorKvart.close();
  
      }
  
      public Zaselenie() {
          // TODO Auto-generated constructor stub
      }
  
      @Override
      protected void onResume() {
          super.onResume();
  
      }
  
      @Override
      protected void onStop() {
          super.onStop();
          // закрываем соединения с базой данных
          sdb.close();
          kdb.close();
      }
  }
  </code></pre>
  
  <p>Logcat error:</p>
  
  <pre><code>03-06 12:04:43.802: E/AndroidRuntime(20861): FATAL EXCEPTION: main
  03-06 12:04:43.802: E/AndroidRuntime(20861): java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.zloyel.manager_sutochnoy_arendy_1/ru.zloyel.manager_sutochnoy_arendy_1.Zaselenie}: java.lang.NullPointerException
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.os.Handler.dispatchMessage(Handler.java:99)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.os.Looper.loop(Looper.java:137)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.ActivityThread.main(ActivityThread.java:4745)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at java.lang.reflect.Method.invoke(Method.java:511)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at dalvik.system.NativeStart.main(Native Method)
  03-06 12:04:43.802: E/AndroidRuntime(20861): Caused by: java.lang.NullPointerException
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at ru.zloyel.manager_sutochnoy_arendy_1.Zaselenie.onCreate(Zaselenie.java:39)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.Activity.performCreate(Activity.java:5008)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  03-06 12:04:43.802: E/AndroidRuntime(20861):    ... 11 more
  </code></pre>