android - Sqlite database size compare with local db size -


i have got sdcard database file , app sqlite database how compare size? when run code below, crashing..

   private contextwrapper context;   @override protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      file extstore = environment.getexternalstoragedirectory();     file myfile = new file(extstore.getabsolutepath() + externalpath             + filename);      file f = context.getdatabasepath(db_path);     long dbsize = f.length();      if (dbsize <= myfile.length()) {              //code here       } else {        } 

appreciate help…

 05-18 02:33:05.410: e/androidruntime(1085): fatal exception: main  05-18 02:33:05.410: e/androidruntime(1085): process:    in.wptrafficanalyzer.searchdialogdemo, pid: 1085  05-18 02:33:05.410: e/androidruntime(1085): java.lang.runtimeexception: unable start  activity  componentinfo{in.wptrafficanalyzer.searchdialogdemo/in.wptrafficanalyzer.searchdialogdemo.lite activity}: java.lang.nullpointerexception  05-18 02:33:05.410: e/androidruntime(1085):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2195)  05-18 02:33:05.410: e/androidruntime(1085):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245)  05-18 02:33:05.410: e/androidruntime(1085): caused by: java.lang.nullpointerexception  05-18 02:33:05.410: e/androidruntime(1085):    @ in.wptrafficanalyzer.searchdialogdemo.liteactivity.oncreate(liteactivity.java:65)  05-18 02:33:05.410: e/androidruntime(1085):    @ android.app.activity.performcreate(activity.java:5231)  05-18 02:33:05.410: e/androidruntime(1085):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087)  05-18 02:33:05.410: e/androidruntime(1085):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2159)  05-18 02:33:05.410: e/androidruntime(1085):    ... 11 more 

your context null have not initialized it.

since you're running in method of activity, there's no point storing context member variable. use this instead. replace

context.getdatabasepath(db_path); 

with just

getdatabasepath(db_path); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -