1.我打开app就需要greendao3 里面的数据 请问 初始化数据应该是写到哪里
2.我写到application当中 只要一启动app 就有加载applicaton,这样发现一打开app 数据就有了
但是当app被后台杀死后,在重新打开app的时候 数据重复了 原因我已经知道 所以这个问题 就是 我只需要第一次的数据加载 也就是说一打开app 只要加载一次数据就可以了 所以请问 这个插入的数据应该是写到哪里
伊谢尔伦2017-04-18 09:15:14
Two ideas:
1. Use SharedPreferences to save the initialization state. Set it to false at the beginning, and set it to true after opening and loading. Get and judge the status first every time you log in
2. Open the app for the first time, load the data, and then delete the data. Open the app later and get the data. If you cannot get it, it means it has been initialized.
PHP中文网2017-04-18 09:15:14
Later, I asked my friends from the previous school to solve the problem of data duplication. I just need to add a judgment in the application if it is the first time to open the app. Use the value stored in an option to save this state, and then judge in the application if it is the first time. Open the app and insert the initialization data. If not, do not insert the data. This solves the problem of data duplication