简体   繁体   English

在android中存储本地的最佳方法是什么?

[英]What is the best way to store local in android?

I have to build a quiz app with 1500 questions .I only need one random question . 我必须建立一个有1500个问题的测验应用程序。我只需要一个随机问题。 so i don't really have to load all the questions once .. What is the best way to store those questions sql,json,xml ? 所以我真的不必一次加载所有问题..什么是存储这些问题的最佳方法sql,json,xml?

Probably with that amount of questions, I'd go by using a SQL database. 可能有这么多问题,我会使用SQL数据库。 It depends, however, what kind of choose, if local or a centralized one. 然而,这取决于什么样的选择,如果是本地的或集中的。

If you plan to change the questions from time to time, you can have a relatively strong server where the users might connect to a webservice and get the questions, I'd recommend a centralized storage database. 如果您计划不时更改问题,您可以拥有一个相对强大的服务器,用户可以连接到Web服务并获取问题,我建议使用集中存储数据库。

If you plan to not change them, they'll be static, or the same for all users, or you can't simply afford having a remote server, use a SQLite database which is local to every device, and each time you start your app, simply load the questions (or do queries when you need to get them). 如果您打算不更改它们,它们将是静态的,或者对所有用户都是相同的,或者您不能简单地负担得起远程服务器,使用每个设备本地的SQLite数据库,并且每次启动时应用程序,只需加载问题(或在需要时进行查询)。

In my oppinion, the best way in your case is to save all data on server, and when it nessery - create Post request to server and get data from it. 在我看来,在你的情况下,最好的方法是将所有数据保存在服务器上,当它成为nessery时 - 创建Post请求到服务器并从中获取数据。 If you want to store your data on phone, and use this data offline - SQLite is the best solution, about it you can read in this great tutorial 如果你想将你的数据存储在手机上,并且离线使用这些数据 - SQLite是最好的解决方案,你可以在这篇精彩的教程中阅读

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM