Trying out site parse.com load data into the database

```
@Override
  public void onClick(View v) {

    cv = new ContentValues();

    db = dbHelper.getWritableDatabase();        

    switch (v.getId()) {

    case R.id.btnAdd:

            query = new ParseQuery("mens");
               query.setLimit(50);             
                query.findInBackground(new FindCallback() {
                public void done(List<ParseObject> mens, ParseException e) {
                  if (e == null) {
                        for ( int i = 0; i < 50; i++) {    

                             stGet = mens.get(i).getString("Str");                                 
                             cv.put("email", stGet);

                             long rowID = db.insert("mytable", null, cv);

                            }                
                     } 
                  }
                 });             

      break;

    dbHelper.close();
}

```

class DBHelper extends SQLiteOpenHelper {

```
    public DBHelper(Context context) {
          super(context, "myDB", null, 1);

    }

    @Override
    public void onCreate(SQLiteDatabase db) {

      db.execSQL("create table mytable ("
          + "id integer primary key autoincrement,"
          + "email text" + ");");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
  }

```

On the emulator get

> 
> java.lang.IllegalStateException: attempt to re-open an already-closed
>  object: SQLiteDatabase: /data/data/com.project.test/databases/myDB at
>  android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
>  at
>  android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:
>  1437) at
>  android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
>  at com.project.test.MainActivity$1.done(MainActivity.java:347) at
>  com.parse.FindCallback.internalDone(FindCallback.java:48) at
>  com.parse.FindCallback.internalDone(FindCallback.java:33) at
>  com.parse.BackgroundTask.onPostExecute(BackgroundTask.java:50) at
>  com.parse.BackgroundTask.onPostExecute(BackgroundTask.java:16) at
>  android.os.AsyncTask.finish(AsyncTask.java:631) at
>  android.os.AsyncTask.access$600(AsyncTask.java:177) at
>  android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
>  at android.os.Handler.dispatchMessage(Handler.java:99) at
>  android.os.Looper.loop(Looper.java:137) at
>  android.app.ActivityThread.main(ActivityThread.java:5103) at
>  java.lang.reflect.Method.invokeNative(Native Method) at
>  java.lang.reflect.Method.invoke(Method.java:525) at
>  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
>  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at
>  dalvik.system.NativeStart.main(Native Method)
> 
> 
> 

On a real device

> 
> FATAL EXCEPTION: main java.lang.IllegalStateException: database not
>  open at
>  android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:
>  1671) at
>  android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1571)
>  at com.project.test.MainActivity$1.done(MainActivity.java:347) at
>  com.parse.FindCallback.internalDone(FindCallback.java:48) at
>  com.parse.FindCallback.internalDone(FindCallback.java:33) at
>  com.parse.BackgroundTask.onPostExecute(BackgroundTask.java:50) at
>  com.parse.BackgroundTask.onPostExecute(BackgroundTask.java:16) at
>  android.os.AsyncTask.finish(AsyncTask.java:417) at
>  android.os.AsyncTask.access$300(AsyncTask.java:127) at
>  android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
>  at android.os.Handler.dispatchMessage(Handler.java:99) at
>  android.os.Looper.loop(Looper.java:130) at
>  android.app.ActivityThread.main(ActivityThread.java:3687) at
>  java.lang.reflect.Method.invokeNative(Native Method) at
>  java.lang.reflect.Method.invoke(Method.java:507) at
>  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
>  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) at
>  dalvik.system.NativeStart.main(Native Method)
> 
> 
> 

long rowID = db.insert("mytable", null, cv); // MainActivity.java:347

What's the problem?