Android Sqlite 存储限制 [英] Android Sqlite Storage Limit

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

问题描述

我正在开发一个 android 应用程序,它每 30 秒获取一次用户位置并存储在应用程序自己的 sqlite 数据库中.在我的计算中,我需要存储大约 1 个 Lac 记录.我只有一张桌子,上面有以下详细信息,ID(整数)、纬度(实数)、经度(实数)、日期(文本)、时间(文本).

I am developing an android application, which takes user location in every 30 seconds and storing in the application's own sqlite db. In my calculation I need to store around 1 Lac records. I have only 1 table with following details, ID(Integer), latitude(real), longitude(real), date(text), time(text).

将详细信息存储在 sqlite 中是否安全?

Is it safe to store the details in sqlite?

它是否会导致性能方面的任何问题.

Will it cause any problem in regards to performance.

请帮帮我.

推荐答案

SQLite 的限制通常对移动设备不感兴趣.设备受到的限制要大得多.

SQLite's limits are usually not of interest on mobile devices. The device is by far more constrained.

例如,如果您每 30 秒添加 1kB 的数据,您每年将生成大约 60GB 的数据.这不适合任何设备,但对 SQLite 来说没有问题.

For example if you add 1kB of data each 30 seconds you'll generate around 60GB of data per year. That's not going to fit on any device but would be no problem for SQLite.

如果您的查询速度很慢,则性能可能会成为问题.索引查询以 log(N) 时间的某种变化运行,这意味着处理数十亿行数据的性能与几千行大致相同.如果您的查询很复杂,您很容易陷入 N^2 或更糟的复杂度,这意味着一旦达到一千行,性能就会很糟糕.在这里多一点:http://www.sqlite.org/queryplanner.html

Performance can be a problem if your queries are slow. Indexed queries run in some variation of log(N) time which means that working with billions of row of data has roughly the same performance as a few thousand. If your queries are complex you can easily get into N^2 complexity or worse meaning that performance will be terrible once you reach like a thousand rows. A bit more here: http://www.sqlite.org/queryplanner.html

我建议记住这个大小限制,并在没有足够空间的情况下添加一种方法来回收数据.内部存储空间(空间不足,无法安装新应用?)通常非常有限.

I would recommend to keep that size limit in mind and add a way to recycle data if there is not enough space. The internal storage (not enough space to install new apps?) is typically very limited.

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

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