android - Gettine Exception: java.lang.IllegalStateException: database not open -


although common error , there may many posts related exception. here strange situation. getting java.lang.illegalstateexception: database not open exception in android 2.2. in remaining mobiles working well.

logcat:

java.lang.illegalstateexception: database not open @ android.database.sqlite.sqlitedatabase.querywithfactory(sqlitedatabase.java:1291) @ android.database.sqlite.sqlitedatabase.query(sqlitedatabase.java:1251) @ android.database.sqlite.sqlitedatabase.query(sqlitedatabase.java:1331) @ com.mythrii.ilpa.datahelper.checkrating(datahelper.java:126) @ com.mythrii.ilpa.splashactivity$1.run(splashactivity.java:35) @ android.os.handler.handlecallback(handler.java:587) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:144) @ android.app.activitythread.main(activitythread.java:4937) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:521) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:858) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) @ dalvik.system.nativestart.main(native method) 

my code:

public class splashactivity extends activityhelper { private datahelper dh; // set display time, in milliseconds (or extract out configurable parameter) private final int splash_display_length = 3000; protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.act__splash);      dh = new datahelper(this);      dh.inserorupdaterating(); }  protected void onresume() {     super.onresume();          new handler().postdelayed(new runnable()         {             public void run()             {                 clearpref();                 prefbooledit("rating",dh.checkrating());//=> here exception                 splashactivity.this.finish();                 intent mainintent = new intent(splashactivity.this, homeactivity.class);                 splashactivity.this.startactivity(mainintent);             }         }, splash_display_length);  }  protected void ondestroy()  {     super.ondestroy();     if (dh != null)      {         dh.close();     } } } 

i using constructor call in every activity

datahelper

 public datahelper(context context)     {        this.context  =   context;       openhelper    =   new openhelper(this.context);       this.db       =   openhelper.getwritabledatabase();        calendar c = calendar.getinstance();           formatteddate = df.format(c.gettime());    } 

checkrating

   public boolean checkrating()    {        cursor cursor = this.db.query(table_name_1, new string[] { "option" },                null, null, null, null, null);         string option = null;        //string date = null;         boolean bool = false;         if (cursor.movetofirst())           {               {                   //date     = cursor.getstring(0);                   option = cursor.getstring(0);                 } while (cursor.movetonext());           }           if (cursor != null && !cursor.isclosed()) {               cursor.close();           }            if(getratecount()>0)           {               if(!option.equals(already_rated))               {                   bool = true;               }               else                {                   bool = false;               }           }           else            {                 bool = false;           }          return bool;    } 

can me please..

before perform operation should open database

dh.open(); 

see one , also one


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -