Android 自动完成文本多少数据量过多
我正在研究对数据库使用自动完成功能。数据库中有大约 10,000 个我需要查询的表。
我一直在尝试寻找示例代码来展示其工作原理,但尚未找到任何东西。假设该表有 ID 和描述。我需要在自动完成中搜索描述。我找到了搜索联系人数据库的代码,但我不太了解 Java,无法将这个想法转换为我自己的 SQLLite 数据库。
如果我有代码来测试这个,我猜我可以回答我自己的问题。只是想知道 10k 条记录是否太多并且会减慢完成速度?
有人对此有什么想法吗?还有人有详细的代码来说明它是如何工作的吗?
谢谢你!
I am looking into using the AutoComplete against a database. The DB has about 10,000 for the table I need to query.
I have been trying to find sample code to show how this works, but yet to find anything. Suppose the table has ID and Description. I need to search against the Description in the AutoComplete. I found code to search the contacts DB but I do not know Java well enough to convert t that idea to my own SQLLite DB.
If I had the code to test this I could answer my own question I would guess. Just wondering if the 10k records would be too much and would slow it done?
Does anyone have any thoughts on this and also does anyone have detailed code that shows how this works?
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于大多数 Android 设备来说,10K 内存字符串太多了。假设您没有收到 OutOfMemoryException 错误,您的应用程序将不断进行垃圾收集,并且您的性能将因此受到影响。假设您的字符串具有平均长度(大约 128 个字符长),我建议在任何给定时间在内存中存储的字符数不超过 250 个。
更好的方法是重复从数据库中获取数据;每次获取大约 15 条记录。
10K in-memory strings would be too much for most Android devices. Assuming you don't get an OutOfMemoryException error, your app will constantly garbage-collect, and your performance will suffer as a result. Assuming your strings are of average length (around 128 characters long), I would recommend storing no more than 250 in memory at any given time.
A better approach would be to repeatedly fetch data from the database; grabbing around 15 records per fetch.