在 ormlite 中获取旧的 Dao 对象
我在我的 Android 应用程序中使用 ormlite 作为 sqlite 数据库。这是一个基于登录的应用程序,我在 SD 卡中有数据库。对于用户 abc,要求是当用户使用 xyz 等不同用户登录时,应用程序从服务器对用户进行身份验证,并且服务器替换用户 xyz 的数据库。但是,当我尝试访问登录凭据时,它会提供旧凭据,而数据库则反映新凭据。
我也尝试过:
DaoManager.clearCache();
它不起作用,我也尝试过:
DatabaseManager<DatabaseHelper> manager = new DatabaseManager<DatabaseHelper>();
manager.releaseHelper(DatabaseHelperGenerator.getDataBaseHelperInstance())
此后,当我尝试触发此查询时:
Dao<LoginAuthentication, Integer> loginAuthenticationDao = null;
DatabaseHelperGenerator.getDataBaseHelperInstance().
clearLoginDao(LoginAuthentication.class);
loginAuthenticationDao = DatabaseHelperGenerator.getDataBaseHelperInstance().
getUserDao(LoginAuthentication.class);
List<LoginAuthentication> loginAuthenticationList =
loginAuthenticationDao.queryForAll();
它给出 IllegalStateException :数据库未打开
寻求帮助。
I am using ormlite for sqlite database in my android application. It's a login based application and I have database in SD card. For user abc, the requirement is when user login with different user like xyz then application authenticate the user from the server and server replace the db for user xyz. But when I am trying to access the login credentials it is giving the old credentials while the database is reflecting the new credentials.
I also tried:
DaoManager.clearCache();
It is not working also I tried:
DatabaseManager<DatabaseHelper> manager = new DatabaseManager<DatabaseHelper>();
manager.releaseHelper(DatabaseHelperGenerator.getDataBaseHelperInstance())
After this when I tried to fire this query:
Dao<LoginAuthentication, Integer> loginAuthenticationDao = null;
DatabaseHelperGenerator.getDataBaseHelperInstance().
clearLoginDao(LoginAuthentication.class);
loginAuthenticationDao = DatabaseHelperGenerator.getDataBaseHelperInstance().
getUserDao(LoginAuthentication.class);
List<LoginAuthentication> loginAuthenticationList =
loginAuthenticationDao.queryForAll();
It is giving IllegalStateException :Database not open
Looking for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,你在这里走错了方向。
IllegalStateException
的原因。我会对您的应用程序进行一些调试或记录一些值以查看问题所在。以下是一些想法:
祝你好运。
Seems to me that you are going in the wrong direction here.
IllegalStateException
.I'd do some debugging of your application or some logging of values to see where the problem lies. Here are some thoughts:
Best of luck.