title: android i got an exception for SQLiteDatabase
body: <p>Following is the exception </p>
  
  <pre><code>08-28 01:38:41.164: E/StrictMode(1308): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
  08-28 01:38:41.164: E/StrictMode(1308): java.lang.Throwable: Explicit termination method 'close' not called
  08-28 01:38:41.164: E/StrictMode(1308):     at dalvik.system.CloseGuard.open(CloseGuard.java:184)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:805)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:944)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:256)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:188)
  08-28 01:38:41.164: E/StrictMode(1308):     at com.s5.selfiemonkey1.helper.LoginHelper.getOfflineData(LoginHelper.java:71)
  08-28 01:38:41.164: E/StrictMode(1308):     at com.s5.selfiemonkey1.fragment.PollImageFragment.onCreateView(PollImageFragment.java:165)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.Fragment.performCreateView(Fragment.java:1700)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.BackStackRecord.run(BackStackRecord.java:684)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.os.Handler.handleCallback(Handler.java:733)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.os.Handler.dispatchMessage(Handler.java:95)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.os.Looper.loop(Looper.java:137)
  08-28 01:38:41.164: E/StrictMode(1308):     at android.app.ActivityThread.main(ActivityThread.java:4998)
  08-28 01:38:41.164: E/StrictMode(1308):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-28 01:38:41.164: E/StrictMode(1308):     at java.lang.reflect.Method.invoke(Method.java:515)
  08-28 01:38:41.164: E/StrictMode(1308):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
  08-28 01:38:41.164: E/StrictMode(1308):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
  08-28 01:38:41.164: E/StrictMode(1308):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p><b>[EDIT]</b>
  Code:</p>
  
  <pre><code>public String getOfflineData(String type){ 
      String offlineData = null; Cursor cursor = null; 
      SQLiteDatabase db = this.getReadableDatabase(); 
      try { 
          cursor = db.rawQuery("select datavalue from offline_data where type='"+type+"'", null); 
          if(cursor.moveToFirst()) {
             offlineData= cursor.getString(0); 
          } 
          cursor.close(); 
       } catch(Exception e) {
           e.printStackTrace(); 
       } finally { 
          if(cursor!=null) cursor.close(); 
          db.close(); 
       }
       return offlineData; 
  } 
  </code></pre>