title: Java.lang.IllegalStateException: attempt to re-open an already-closed?
body: <p>I got error from my Sqlite Android. I have code like this:</p>
  
  <pre><code>public int UpdatePhotoUser(String foto_user, int metode) {
  
          SQLiteDatabase db = this.getWritableDatabase();
          ContentValues values = new ContentValues();
          int update = 0;
  
          if (metode == 1) {
              values.put(Variabel.KEY_USER_PHOTO, foto_user);
              try {
                  update = db.update(
                          Variabel.TABLE_USER,
                          values, null, null);
              } catch (android.database.sqlite.SQLiteException e) {
  
              }
          } else if (metode == 2 &amp;&amp; getUserDetails(Variabel.KEY_USER_PHOTO).equals(foto_user)) {
              values.put(Variabel.KEY_USER_PHOTO, "");
              try {
                  update = db.update(
                          Variabel.TABLE_USER,
                          values, null, null);
              } catch (android.database.sqlite.SQLiteException e) {
  
              }
          }
  
          db.close();
          return update;
      }
  </code></pre>
  
  <p>And I have Error at last line:</p>
  
  <pre><code>update = db.update(
                              Variabel.TABLE_USER,
                              values, null, null);
  </code></pre>
  
  <p>This the eror:</p>
  
  <pre><code>Java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.ad.kamardagang.newseditor/databases/DB_KAMAR_DAGANG
              at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
              at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1545)
              at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1522)
              at com.ad.kamardagang.newseditor.database_content.DatabaseHandler.UpdatePhotoUser(DatabaseHandler.java:613)
              at com.ad.kamardagang.newseditor.fragments.PhotoUserFragment.removeRespone(PhotoUserFragment.java:985)
              at com.ad.kamardagang.newseditor.fragments.PhotoUserFragment.access$600(PhotoUserFragment.java:62)
              at com.ad.kamardagang.newseditor.fragments.PhotoUserFragment$12.onResponse(PhotoUserFragment.java:879)
              at com.ad.kamardagang.newseditor.fragments.PhotoUserFragment$12.onResponse(PhotoUserFragment.java:875)
              at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
              at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
              at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5254)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  </code></pre>
  
  <p><strong>edited:</strong>
  exmple I call with :</p>
  
  <pre><code>db = new DatabaseHandler(getActivity());
   db.UpdatePhotoUser("http://a.png",1);
  </code></pre>
  
  <p>when. I <strong>first</strong> call metode <strong>UpdatePhotoUser(String foto_user, int metode)</strong>, but on <strong>second</strong> call its error. so how to fix it ?</p>