如何将新数据推送到 Android SQLite 数据库
我正在创建一个应用程序,它将成为唱片专辑发行的数据库。初始数据库将包含过去几年专辑发行的历史记录。
我想每周将新专辑发行的数据推送到应用程序。如果不每周重新发布整个应用程序,我该如何去做呢?
预先感谢您的任何帮助。
I am creating an App that will be a database of record album releases. The initial database will contain a history of album releases for the past few years.
I'd like push the data for new album releases to the application each week. How would I go about doing this without republishing the entire app each week?
Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您需要网络服务来进行更新。
然后,您的应用程序可以连接并要求自上次启动应用程序时进行检查(以避免重新获取所有数据)以来的所有更改。
新数据可以通过
INSERT
添加到应用程序的现有 SQL 数据库(或UPDATE
,以防现有行发生更改),然后可用于离线用法/搜索等。请参阅 http://developer.android.com/reference /android/database/sqlite/SQLiteDatabase.html 了解数据库上可能的方法。对于编写操作,最好使用围绕它的事务。
另一种可能性是使用推送到设备。但只有当您想通知用户有新内容可用时才需要这样做。在这里找到一篇关于此的好文章:http://tokudu。 com/2010/how-to-implement-push-notifications-for-android/ 但我自己没有经验。
祝您的应用程序好运。
I would suggest you need a web service for the update.
Your app can then connect and ask for all changes since its last check (to avoid re-fetching all data) on starting the app.
The new data can be added to the existing sql data base of the app with
INSERT
(orUPDATE
in case changes of existing rows are possible too) and is afterwards available for offline usage / searching etc.See http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html for possible methods on a database. With writing actions it's a good idea to use a transaction around it.
The other possibility would be to use push to device. But that would only be needed in case you want to inform the user, that something new is available. Found a nice article about this here: http://tokudu.com/2010/how-to-implement-push-notifications-for-android/ but have no experience with it myself.
Good luck with your app.