title: java.lang.RuntimeException: Unable to start activity ComponentInfo{...EditCity}: java.lang.NullPointerException
body: <p>this is the xml file.                                                                                                           </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_marginLeft="20dp"
      android:layout_marginTop="15dp"
      android:text="@string/edit_city"
      android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;TextView
      android:id="@+id/textView3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView2"
      android:layout_below="@+id/cityName"
      android:layout_marginTop="20dp"
      android:text="@string/country_name" /&gt;
  
  &lt;EditText
      android:id="@+id/countryName"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/textView3"
      android:layout_alignLeft="@+id/cityName"
      android:ems="10"
      android:inputType="text" /&gt;
  
  &lt;TextView
      android:id="@+id/textView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_above="@+id/countryName"
      android:layout_alignLeft="@+id/textView1"
      android:text="@string/city_name" /&gt;
  
  &lt;EditText
      android:id="@+id/cityName"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/textView1"
      android:layout_toRightOf="@+id/textView1"
      android:ems="10"
      android:inputType="text" /&gt;
  
  &lt;TextView
      android:id="@+id/textView4"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView3"
      android:layout_below="@+id/textView3"
      android:layout_marginTop="20dp"
      android:text="@string/population" /&gt;
  
  &lt;EditText
      android:id="@+id/population"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/textView4"
      android:layout_alignLeft="@+id/countryName"
      android:ems="10"
      android:inputType="text" &gt;
  
      &lt;requestFocus /&gt;
  &lt;/EditText&gt;
  
  &lt;TextView
      android:id="@+id/textView5"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView4"
      android:layout_below="@+id/textView4"
      android:layout_marginTop="20dp"
      android:text="@string/traditions" /&gt;
  
  &lt;EditText
      android:id="@+id/traditions"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/textView5"
      android:layout_alignLeft="@+id/population"
      android:ems="10"
      android:inputType="text" /&gt;
  
  &lt;TextView
      android:id="@+id/textView6"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView5"
      android:layout_below="@+id/textView5"
      android:layout_marginTop="21dp"
      android:text="@string/impressions" /&gt;
  
  &lt;EditText
      android:id="@+id/impressions"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/textView6"
      android:layout_alignParentRight="true"
      android:ems="10"
      android:inputType="text" /&gt;
  
  &lt;TextView
      android:id="@+id/textView7"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView6"
      android:layout_below="@+id/textView6"
      android:layout_marginTop="21dp"
      android:text="@string/url_image" /&gt;
  
  &lt;EditText
      android:id="@+id/urlImage"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/textView7"
      android:layout_alignParentRight="true"
      android:ems="10"
      android:inputType="text" /&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_marginBottom="38dp"
      android:layout_toRightOf="@+id/textView3"
      android:background="#444444"
      android:textColor="#FFFFFF"
      android:onClick="editCity"
      android:text="@string/edit_button" /&gt;
  
  &lt;Button
      android:id="@+id/button2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignTop="@+id/button1"
      android:layout_marginLeft="56dp"
      android:layout_toRightOf="@+id/button1"
      android:background="#444444"
      android:onClick="displayCity"
      android:text="@string/view_button"
      android:textColor="#FFFFFF"
      android:textSize="20sp" /&gt;
  
    &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>this is the logcat content.                                                                                         </p>
  
  <pre><code>09-10 16:55:15.975: D/AndroidRuntime(297): Shutting down VM
  09-10 16:55:15.975: W/dalvikvm(297): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  09-10 16:55:15.995: E/AndroidRuntime(297): FATAL EXCEPTION: main
  09-10 16:55:15.995: E/AndroidRuntime(297): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.citiestoremember/com.example.citiestoremember.EditCity}: java.lang.NullPointerException
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.os.Handler.dispatchMessage(Handler.java:99)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.os.Looper.loop(Looper.java:123)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at java.lang.reflect.Method.invokeNative(Native Method)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at java.lang.reflect.Method.invoke(Method.java:521)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at dalvik.system.NativeStart.main(Native Method)
  09-10 16:55:15.995: E/AndroidRuntime(297): Caused by: java.lang.NullPointerException
  09-10 16:55:15.995: E/AndroidRuntime(297):  at com.example.citiestoremember.EditCity.onCreate(EditCity.java:44)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  09-10 16:55:15.995: E/AndroidRuntime(297):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  09-10 16:55:15.995: E/AndroidRuntime(297):  ... 11 more
  </code></pre>
  
  <p>Hello! When I run my program it goes well until a specific moment.I get this error in my logcat.</p>
  
  <p>The EditCity.java file where the error occures is below. Can anyone help me ? Thank you!</p>
  
  <pre><code>package com.example.citiestoremember;
  
  import java.util.HashMap;
  
  import android.app.Activity;
  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.EditText;
  
  public class EditCity extends Activity{
  
  EditText cityName;
  EditText countryName;
  EditText populationNumber;
  EditText traditions;
  EditText impressions;
  EditText urlImage;
  
  DBTools dbTools = new DBTools(this);
  
  public void onCreate(Bundle savedInstanceState){
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.edit_city);
      cityName = (EditText) findViewById(R.id.cityName);
      countryName = (EditText) findViewById(R.id.countryName);
      populationNumber = (EditText) findViewById(R.id.populationNumber);
      traditions = (EditText) findViewById(R.id.traditions);
      impressions = (EditText) findViewById(R.id.impressions);
      urlImage = (EditText) findViewById(R.id.urlImage);
  
      Intent theIntent = getIntent();
  
      String cityId = theIntent.getStringExtra("cityId");
  
      HashMap&lt;String, String&gt; cityList = dbTools.getCityInfo(cityId);
  
      if(cityList.size() != 0){
  
          cityName.setText(cityList.get("cityName"));
          countryName.setText(cityList.get("countryName"));
          populationNumber.setText(cityList.get("populationNumber"));
          traditions.setText(cityList.get("traditions"));
          impressions.setText(cityList.get("impressions"));
          urlImage.setText(cityList.get("urlImage"));
  
      }
  }
  
  public void editCity(View view){
  
      HashMap&lt;String, String&gt; queryValuesMap = new HashMap&lt;String, String&gt;();
  
      cityName = (EditText) findViewById(R.id.cityName);
      countryName = (EditText) findViewById(R.id.countryName);
      populationNumber = (EditText) findViewById(R.id.populationNumber);
      traditions = (EditText) findViewById(R.id.traditions);
      impressions = (EditText) findViewById(R.id.impressions);
      urlImage = (EditText) findViewById(R.id.urlImage);
  
      Intent theIntent = getIntent();
  
      String cityId = theIntent.getStringExtra("cityId");
  
      queryValuesMap.put("cityId", cityId);
      queryValuesMap.put("cityName", cityName.getText().toString());
      queryValuesMap.put("countryName", countryName.getText().toString());
      queryValuesMap.put("populationNumber", populationNumber.getText().toString());
      queryValuesMap.put("traditions", traditions.getText().toString());
      queryValuesMap.put("impressions", impressions.getText().toString());
      queryValuesMap.put("urlImage", urlImage.getText().toString());
  
      dbTools.updateCity(queryValuesMap);
      this.callMainActivity(view);
  
  }
  
  public void displayCity(View view){
  
      Intent theIntent = new Intent(getApplicationContext(), DisplayImage.class);
      String urlImage = theIntent.getStringExtra("urlImage");
      theIntent.putExtra("urlImage", urlImage); 
  
      startActivity(theIntent);
  
  }
  
  public void callMainActivity(View view){
  
      Intent objIntent = new Intent(getApplication(), MainActivity.class);
  
      startActivity(objIntent);
  
  }
  
   }
  </code></pre>