title: android-sqlite - isOpen returns nullpointerexception in SQLiteOpenHelper
body: <p>This is my database class:</p>
  
  <pre><code>public class OpenHelper extends SQLiteOpenHelper {
  Context context;
  
  public OpenHelper(Context context) {
      super(context, TABLE_NAME, null, VERSION);
      this.context = context;
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
      // Category table create query
      ........
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
  }
  public DatabaseHandler open() {
          helper = new OpenHelper(context);
          myDB = helper.getWritableDatabase();
          return this;
      }
  
      public void close() {
          myDB.close();
      }
  
      public boolean isOpen() {
          if(myDB.isOpen()) return true ; else return false; 
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Every function I have works fine like insert and update, but when I want to check if the database is open or not, it crashes. I call it in activity like this:</p>
  
  <pre><code>DatabaseHandler mydb=new DatabaseHandler(context);
              if(!mydb.isOpen())
                  mydb.open();
  </code></pre>
  
  <p>It keeps erroring on this line:</p>
  
  <pre><code>if(!mydb.isOpen())
  </code></pre>
  
  <p>It returns a <code>nullpointerexception</code> and I don't know why.</p>