使用XML存储数据 [英] Using XML to store data

查看:104
本文介绍了使用XML存储数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找使用XML文件存储我的Android应用生成的数据.考虑到这一点,我对社区提出了两个问题:

I am looking to use an XML file to store the data my Android app generates. With that in mind, I have two questions for the community:

  1. XML在Android上存储数据的最佳方法,并且在每秒或少于一秒钟的时间内添加或更改数据的情况下,效率最高.

  1. Is XML the best way to store data on Android and most efficient in cases where data may be added or altered every second or less then a second.

如果XML确实是#1中所述方案的最佳选择,我该如何进行设置?

If XML is indeed the best for the scenario described in #1, how do I go about setting it up?

推荐答案

1.)XML是在android上数据库数据的最佳方法,并且是在每秒或少于一秒钟的时间内添加或更改数据的情况下最有效的方法.

1.) Is XML the best way to database data on android and most efficient in cases where data may be added or altered every second or less then a second.

绝对不是.

2.)如果XML确实是#1中所述方案的最佳选择,我该如何设置它?

2.) If XML is indeed the best for the scenario described in #1, how do I go about setting it up?

如果您打算仅在本地存储数据,则最好的方法是使用SQLite,该SQLite可以在每个设备上用作本地数据库.

If you plan to store data just locally, the best way would be SQLite which works as a local database on every device.

如果以后计划将此数据与中央数据库同步,则可以在定期运行的AsyncTaskThread中异步执行此操作,但到目前为止,将每一秒写入XML文件是一个坏主意随着性能的提高.

If you later plan to synchronize this data with a central database, you may do this asynchronously within an AsyncTask or a Thread which would run periodically, but writing each second into a XML file is a bad idea as far as performance goes.

在每次插入/修改/删除操作中同步远程数据库,就像您有很多用户一样,可以折叠远程数据库,这可能也是一个坏主意.

It's probably also a bad idea synchronizing a remote database at each insert/modification/deletion operation as if you had many users you could collapse the remote database.

我认为最好的方法是(如前所述)在本地数据库中存储数据,并在需要时在远程端实现Web服务,并使用它定期同步两个数据库.

I think the best approach is (as previously said) having a local database where you would store that data, and implement a webservice in the remote side if needed and use it to periodically synchronize both databases.

这篇关于使用XML存储数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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