从优化Web服务的Andr​​oid数据库更新(SQLite的) [英] Optimize Android database update (SQLite) from web service

查看:118
本文介绍了从优化Web服务的Andr​​oid数据库更新(SQLite的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天。

我已经构造了具有从 JSON 服务$ P检索其内容的的SQLite 数据库应用程序$ p-填充使用的MySQL 。每天,有更新,未成年人名称变更或插入,我仍然不确定如何实现本地的SQLite 数据库更新。

I've constructed an app that has an SQLite database that retrieves its contents from a JSON service pre-populated using MySQL. Every day, there is an update, a minor name change or insert, and I'm still unsure on how to implement the local SQLite database update.

所以...我的问题是,我该如何优化我的应用程序的数据库的更新,其中(如果不是实时),它可以检查数据库的变化和每2分钟更新左右,如果有变化,执行背景检查更新和插入(或更新)新的内容,而不是仅仅清理出previous本地数据库,并再次重新填充它。

So... my problem is, how do I optimize the update of my app's database wherein (if not real-time) it can check for database changes and updates every 2 minutes or so if there is a change, perform a background check for updates and insert (or update) the new content instead of just clearing out the previous local database and repopulate it again.

在此先感谢。 :)

推荐答案

您可以试试这个:
只是做一个DBHandler类,并用一个函数与所需的参数插入项到该表中。和一个delete方法,从表中删除所有previous记录。

You can try this : Just make one DBHandler class and write one function to insert the items into that table with necessary parameters. and one delete method to delete all previous records from table.

当你再更新数据的所有数据重新插入到该表。

Whenever you get a updated data then reinsert all data into that table.

这是我目前使用的解决方案之一。

This is one of the solution that i am currently using.

检查:<一href=\"http://stackoverflow.com/questions/7721800/how-to-use-service-to-update-sqlite-database-in-android\">To对于每2分钟更新表

这篇关于从优化Web服务的Andr​​oid数据库更新(SQLite的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆