greenDao: store data in sqlite file on Android -
what recommended way store data in sqlite file located on filesystem of android smartphone? intend restore data after device reboot. difference between "daomaster.createalltables(db, true)" , "daomaster.createalltables(db, false)"?
currently using code in mainactivity.java:
db = sqlitedatabase.openorcreatedatabase(new file(getexternalfilesdir(null).getpath(), "opendao.sqlite"), null); daomaster = new daomaster(db); daomaster.createalltables(db, true); daosession = daomaster.newsession(db); locationentitydao = daosession.getlocationentitydao(); locationtraceentitydao = daosession.getlocationtraceentitydao(); photoentitydao = daosession.getphotoentitydao(); photosentitydao = daosession.getphotosentitydao(); poientitydao = daosession.getpoientitydao(); primitiveattributesentitydao = daosession.getprimitiveattributesentitydao();
i had modify geńerated daomaster.java:
public daosession newsession(sqlitedatabase db) { return new daosession(db, identityscopetype.session, daoconfigmap); }
i'm not quite sure if understand question. mean "device reboot"? factory resset? did follow instructions on greendao web? i've been working greendao while , never modified generated daomaster, should work it's generated. reading code, when use default daomaster.newsession(), db used 1 used in daomaster creation, modification should not necessary.
for second question, if follow generated code, you'll see diference between setting true or false ifnotexist param in createalltables(sqlitedatabase db, boolean ifnotexists). boolean determines if each table in database should created if exists. setted true, if table in database, create command have no effect.
Comments
Post a Comment