title: DBHelper class cannot be instantiated (a subclass of SQLiteOpenHelper) inside the same class
body: <p>I want to acess the database and insert data into the SQLite database.To acess the database i try to instatiate the DBHelper class i created extending the <code>SQLiteOpenHelper</code> class. The constructor of the  the <code>DBHelper</code>class is : </p>
  
  <pre><code>public DBHelper(Context context) {
      super(context, DATABASE_NAME, null, DATABASE_VERSION);
      }
  </code></pre>
  
  <p>So I try to intatiate the class using this code</p>
  
  <pre><code>DBHelper myDb = new DBHelper(getContext());
  </code></pre>
  
  <p>It gives error saying "cannot resolve method getContext();"when <code>getContext()</code> function used as the argument for constructor of the <code>DBHelper</code> class.</p>
  
  <p>The DBHelper class is as follows:</p>
  
  <pre><code>package com.violator.it17250_test1.Database;
  
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  import com.violator.it17250_test1.UserProfile;
  
  public class DBHelper extends SQLiteOpenHelper {
  
  
  private static final String SQL_CREATE_ENTRIES =
          "CREATE TABLE " + UserProfile.Users.TABLE_NAME + " (" +
                  UserProfile.Users.COLUMN_NAME_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
                  UserProfile.Users.COLUMN_NAME_USERNAME + " TEXT," +
                  UserProfile.Users.COLUMN_NAME_DOB + " TEXT, " +
                  UserProfile.Users.COLUMN_NAME_GENDER + "TEXT )";
  
  private static final String SQL_DELETE_ENTRIES =
          "DROP TABLE IF EXISTS " + UserProfile.Users.TABLE_NAME;
  
  
  public static final int DATABASE_VERSION = 1;
  public static final String DATABASE_NAME = "users1.db";
  
  public DBHelper(Context context) {
      super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }
  
  DBHelper myDb = new DBHelper(getContext());
  
  
  @Override
  public void onCreate(SQLiteDatabase db) {
      db.execSQL(SQL_CREATE_ENTRIES);
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      db.execSQL(SQL_DELETE_ENTRIES);
      onCreate(db);
  }
  
  public void addInfo(){
      // Gets the data repository in write mode
      SQLiteDatabase db = myDb.getWritableDatabase();
  }
  
  
  }
  </code></pre>