title: NullPointerException Android Java
body: <p>I'm receiving a nullPointerException error, during one of methods and I can't seem to work out why one of my variables(csID) is becoming null.</p>
  
  <p>here is the method:</p>
  
  <pre><code>public String getSubjectBasedOnHID(int hID) {
      String selectQuerySubjectForHomework = "SELECT sID FROM homework WHERE hID = '"
              + hID + "';";
      HashMap&lt;String, String&gt; sIDD = new HashMap&lt;String, String&gt;();
  
      SQLiteDatabase database = this.getReadableDatabase();
          Cursor cursorGetsID = database.rawQuery(selectQuerySubjectForHomework,
              null);
  
      if (cursorGetsID.moveToFirst()) {
          HashMap&lt;String, String&gt; temp = new HashMap&lt;String, String&gt;();
          temp.put("sID", cursorGetsID.getString(0));
  
          sIDD = temp;
      }
       String csID = sIDD.get("sID").toString();
  
  
  
  
      String Subject = csID;
      return Subject;
  };
  </code></pre>
  
  <p>csID becomes null (I think), which causes the program to crash, any help would be greatly Appreciated!</p>
  
  <p>logCat:</p>
  
  <pre><code>    01-07 18:58:45.854: E/AndroidRuntime(2630): Caused by: java.lang.NullPointerException
  01-07 18:58:45.854: E/AndroidRuntime(2630):     at com.compfour.homework.dataBaseTools2.getSubjectBasedOnHID(dataBaseTools2.java:284)
  </code></pre>
  
  <p>Thank you, in advance.</p>