title: NullPointerException at this.getReadableDatabase();
body: <p>Heyhey :)</p>
  
  <p>I looked at several Questions to the same topic, but I found no solution to my problem.</p>
  
  <p>A NullPointerException at <code>this.getReadableDatabase();</code> appears...</p>
  
  <p>Here's my Code:</p>
  
  <pre><code>public class DatabaseHandler extends SQLiteOpenHelper {
  
  public static final int DATABASE_VERSION = 1;
  
  public static final String DATABASE_NAME = "TODO_APP";
  
  /*--------------------------- TABLE ITEMS START ---------------------------*/
  private static final String TABLE_ITEMS = "items";
  private static String KEY_ID_ITEMS = "id_items";
  private static final String KEY_CATEGORY_ITEMS = "category";
  private static final String KEY_DATETIME_ITEMS = "datetime";
  private static String KEY_NAME_ITEMS = "name";
  private static final String KEY_DESCRIPTION_ITEMS = "description";
  private static final String KEY_ALARM_ITEMS = "alarm";
  
  public DatabaseHandler(Context context) {
      super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
  
      // create table ITEMS
      String CREATE_ITEMS_TABLE = "CREATE TABLE " + TABLE_ITEMS + "("
              + KEY_ID_ITEMS + " INTEGER PRIMARY KEY," + KEY_CATEGORY_ITEMS
              + " INTEGER," + KEY_DATETIME_ITEMS
              + " TIMESTAMP DEFAULT CURRENT_TIMESTAMP," + KEY_NAME_ITEMS
              + " TEXT," + KEY_DESCRIPTION_ITEMS + " TEXT," + KEY_ALARM_ITEMS
              + " INTEGER" + ");";
      db.execSQL(CREATE_ITEMS_TABLE);
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      // Drop older table if existed
      db.execSQL("DROP TABLE IF EXISTS " + TABLE_ITEMS);
  
      // Create tables again
      this.onCreate(db);
  }
  
  public void addItem(DB_Item item) {
      SQLiteDatabase db = this.getWritableDatabase();
  
      ContentValues values = new ContentValues();
      values.put(KEY_CATEGORY_ITEMS, item.getCategory());
      values.put(KEY_NAME_ITEMS, item.getName());
      values.put(KEY_DESCRIPTION_ITEMS, item.getDescription());
      values.put(KEY_ALARM_ITEMS, item.getAlarm());
  
      // Inserting Row
      db.insert(TABLE_ITEMS, null, values);
      db.close(); // Closing database connection
  }
  
  public DB_Item getItem(String name) {
  
  //!!!!! Here is one problem !!!!!
      SQLiteDatabase db = this.getReadableDatabase();
  
      Cursor cursor = db.query(TABLE_ITEMS, new String[] { KEY_ID_ITEMS,
              KEY_CATEGORY_ITEMS, KEY_DATETIME_ITEMS, KEY_NAME_ITEMS,
              KEY_DESCRIPTION_ITEMS, KEY_ALARM_ITEMS },
              KEY_NAME_ITEMS = " = ?", new String[] { String.valueOf(name) },
              null, null, null, null);
      if (cursor != null) {
          cursor.moveToFirst();
      }
  
      // DB_Item (int category, String name, String description, int
      // alarm)
      DB_Item item = new DB_Item(cursor.getInt(1), cursor.getString(3),
              cursor.getString(4), cursor.getInt(5));
  
      return item;
  }
  
  public List&lt;DB_Item&gt; getAllItems() {
      List&lt;DB_Item&gt; itemList = new ArrayList&lt;DB_Item&gt;();
  
      // SELECT ALL
      String selectQuery = "SELECT * FROM " + TABLE_ITEMS;
  
  //!!!!!!!!!! here is the other Problem
      SQLiteDatabase database = this.getWritableDatabase();
  
      Cursor cursor = database.rawQuery(selectQuery, null);
  
      // go through all rows and then adding to list
      if (cursor.moveToFirst()) {
          do {
              DB_Item item = new DB_Item();
              item.setCategory(Integer.parseInt(cursor.getString(0)));
              // TODO
  
              // adding to list
              itemList.add(item);
          } while (cursor.moveToNext());
      }
      return itemList;
  }
  </code></pre>
  
  <p>[and so on, didn't copy the whole code]</p>
  
  <p>Hope you can help me...
  The error appears definitely at  <code>SQLiteDatabase db = this.getReadableDatabase();</code></p>
  
  <p>Output: </p>
  
  <pre><code>09-03 08:34:17.863: E/AndroidRuntime(7074): java.lang.RuntimeException: Unable to start activity ComponentInfo{todo.todo_list/todo.view.StartApp}: java.lang.NullPointerException
  09-03 08:34:17.863: E/AndroidRuntime(7074):     at todo.database.DatabaseHandler.getAllItems(DatabaseHandler.java:144)
  09-03 08:34:17.863: E/AndroidRuntime(7074):     at todo.helper.SortItems.sortItemsCategory(SortItems.java:16)
  09-03 08:34:17.863: E/AndroidRuntime(7074):     at todo.view.StartApp.onCreate(StartApp.java:36)
  </code></pre>