SQLite数据库与文件存储

发布于 2024-11-01 08:18:44 字数 187 浏览 0 评论 0原文

我想存储结构类型数据(即呼叫日志信息,如姓名、号码、号码类型、日期、时间、持续时间)。哪种方法最好,哪种方法更快? SQLiteDatabase(创建表并插入、删除其中的日志)或使用文件存储(意味着为所有参数创建一个类并使用输入/输出流和可序列化将其对象写入文件中)或我听说的另一种方式是 XML 解析器,但是我不知道这个。

请帮我。提前致谢。

I want to store structure type data (i.e. information of call logs like name, number, type of number, date, time, duration). Which is the best way and which is faster? SQLiteDatabase (make table and insert, delete logs in it) or use file storage (means make one class for all parameters and write their objects in file using input/output Stream and serializable) or the another way i heard about it is XML parser but i don't know this.

Please help me. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

能否归途做我良人 2024-11-08 08:18:44

这取决于您想要做什么。

如果您的目标是速度,那么 SQLite 将会给您带来很大的损失(特别是如果您将多个插入包装到事务中)。 SQLite 已经针对您提到的所有内容进行了优化,并且很容易利用它可以为您提供的速度。

如果可移植性是您的目标,那么文件可能会稍微容易一些。文件可以非常轻松地来回移动,而 SQLite 可能需要更多的努力。

如果能够搜索是您的目标,那么您不使用 SQLite 就太傻了,因为它非常擅长搜索和过滤结果。

It depends on what you are trying to do.

If your goal is speed, the SQLite will give you a serious run for your money (especially if you wrap multiple inserts into transactions). SQLite has been optimized for everything you mentioned and it would be very easy to leverage the speed it can give you.

If portability is your goal, then files may be a slight bit easier. Files can be moved back and forth very easily easily, whereas SQLite might take some more effort.

If being able to search is your goal, then you'd be a fool not to use SQLite, as it is extremely good at searching and filtering results.

浅沫记忆 2024-11-08 08:18:44

我无法在这里给出非常明智的答案,因为我和您一样对这个主题很陌生,但这里是开发人员页面的链接,其中介绍了不同类型的数据存储。我希望你觉得它有用。 http://developer.android.com/guide/topics/data/data -storage.html

I can't give a very informed answer here because I'm just as new to the subject as you are, but here is the link from the developers page that goes over the different types of data storage. I hope you find it useful. http://developer.android.com/guide/topics/data/data-storage.html

墨小沫ゞ 2024-11-08 08:18:44

就个人而言,如果您了解数据库的基础知识,我会使用 sqlite 数据库。在 Android 中这非常简单。就速度而言,我不知道哪个更快,但如果你没有数百万个数据集,那也没关系。

Personally, given you know the basics of Databases I would use a sqlite database. It's pretty straight forward in Android. In terms of speed I don't know which is faster, but if you don't have millions of datasets it won't matter.

ぇ气 2024-11-08 08:18:44

根据我的经验,大多数情况下文件中的 JSON 就足够了(大多数情况下您需要存储数组或对象或仅存储单个数字或字符串)。我很少需要SQLite(这需要更多时间来设置和使用它)。

In my experience in most cases JSON in a file is enough (mostly you need to store an array or an object or just a single number or string). I rarely need SQLite (which needs more time for setting it up and using it).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文