[英]How to handle very very large amount of data in Android?
I have a database containing 2 500 000 row of 13-digits numbers (and on end a little bit more - 4 000 000) The user has to find if a 13-digits number exists in this database, all this on his android phone, without any internet connexion.我有一个数据库,其中包含 2 500 000 行 13 位数字(最后还有一点 - 4 000 000) 用户必须查找此数据库中是否存在 13 位数字,所有这些都在他的 android 手机上,没有任何互联网连接。 So what do you suggest to deal with this?
那么你有什么建议来处理这个问题?
I thought about using SQLITE on Android.我考虑过在 Android 上使用 SQLITE。
What do you suggest?你有什么建议?
SQLite will be the best storage option for large data sets on the device. SQLite 将是设备上大型数据集的最佳存储选项。 Ensure that where possible you use the correct SQLite query to get the data you need rather then using a general query and doing processing in your own code.
确保尽可能使用正确的 SQLite 查询来获取所需的数据,而不是使用一般查询并在您自己的代码中进行处理。
This is a bit too much to add in the comments, so I'll add it here.这在评论中添加的有点太多了,所以我会在这里添加。
4,000,000 rows of integers is not that much. 4,000,000 行整数并不是那么多。 Assuming that the integers will use the maximum size of a signed int (8 bytes), your database will be:
假设整数将使用有符号整数的最大大小(8 个字节),您的数据库将是:
4000000 * 8 / 1024 / 1024 = ~30.5mb 4000000 * 8 / 1024 / 1024 = ~30.5mb
That is large, but not game breaking.这是很大的,但不是破坏游戏。
Now that also assumes you will need a full 8 bytes per number.现在还假设每个数字需要完整的 8 个字节。 We know that we want to store 13 digits per entry, so a 6 byte integer column would suffice:
我们知道我们希望每个条目存储 13 位数字,因此 6 字节整数列就足够了:
4000000 * 6 / 1024 / 1024 = ~23mb 4000000 * 6 / 1024 / 1024 = ~23mb
Hi d3cima may be too late answer but it's help other's.嗨 d3cima 可能为时已晚,但它可以帮助其他人。 Myself Realm is the best option.
自己境界是最好的选择。
Realm's developer-friendly platform makes it easy to build reactive apps, realtime collaborative features, and offline-first experiences. Realm 对开发人员友好的平台使构建反应式应用程序、实时协作功能和离线优先体验变得容易。
Advantage's:好处:
faster than SQLite (up to 10x speed up over raw SQLite for normal operations)比 SQLite 快(对于正常操作,速度比原始 SQLite 快 10 倍)
easy to use便于使用
object conversion handled for you为您处理对象转换
convenient for creating and storing data on the fly便于动态创建和存储数据
I used my project it's more than 10 x then Sqlite.我使用了我的项目,它比 Sqlite 多 10 倍。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.