title: SQLite Database Locked in DialogFragment onClick event
body: <p>People say that it may be caused when you don't close cursor or database. But I have something strange. 
  I try to open database on OK button click in a dialogfragment window (resultClass) in MainActivity in the beginning of app.</p>
  
  <p>The method that calls DialogFragment window</p>
  
  <pre><code>@SuppressLint("NewApi")
      public void vasya(View v){
      DialogFragment dlg_rec=new resultClass();
       dlg_rec.show(getFragmentManager(), "dlg_rec");}
  </code></pre>
  
  <p>in my DialogFragment class</p>
  
  <pre><code>public Score_DS dsoop=new Score_DS(getActivity());
  
  ..
  case R.id.button1:
  
          dsoop.open();// Here comes the crash
             ...
              dsoop.close();
  </code></pre>
  
  <p>Score_DS is my DataSource class to operate with database.</p>
  
  <pre><code>public class Score_DS {
      ContentValues cv= new ContentValues();
      DB dbHelper;
      SQLiteDatabase db;
       public Score_DS(Context context) {
              dbHelper = new DB(context);
            }
      public void open() throws SQLException {
          if (dbHelper != null) {
              db = dbHelper.getWritableDatabase();
          }
      }
  ...
        (here I have a couple of methods that I've never called yet)
  }
  </code></pre>
  
  <p>DB.java is this</p>
  
  <pre><code>package com.wordpress.jimmaru.tutorial.SimpleGame;
  
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.provider.BaseColumns;
  
  public class DB extends SQLiteOpenHelper implements BaseColumns{
  
      private static final String DATABASE_NAME = "mygame.db";
      private static final int DATABASE_VERSION = 1;
      private static DB sInstance;
      ContentValues cv;
       public DB(Context context) {
  
           super(context, DATABASE_NAME, null, DATABASE_VERSION);}
  
  
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          // TODO Auto-generated method stub
          db.execSQL("CREATE TABLE Records(_id INTEGER PRIMARY KEY,   Player_Name VARCHAR(50), Player_Score VARCHAR(50));");
  
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion) {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>So, again. I call DialogFragment window in the very beginning of my app by clicking on a button. When I click on OK button in my dialogfragment window, the app crashes and shows that Database is locked. I closed everything (db.close). I have no cursors opened. in MainActivity I have another database related method.</p>
  
  <pre><code>Score_DS dseed=new Score_DS(this);
  ...
  public void clearall(View v)
      {
           dseed.open();
           dseed.execution("DELETE FROM Records");
            dseed.close();
      }
  </code></pre>
  
  <p>And it works just fine. 
   What can be wrong?</p>