存储Android应用简单的数据 [英] Storing simple data in android app

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

问题描述

我做一个简单的GPA Android应用程序。用户可以输入自己的档次和类名,每学期。我怎么会那么存储这些学期,使他们能够始终在应用上拉的?我可能还需要存储都不在话下随机变量。

I'm making a simple GPA android app. The user can input their grades and class names for each semester. How would I then store each of these semesters so that they can always be pulled up in the app? I might also need to store random variables that are alone.

我简要地看着选项,如共享preferences,内部存储,等等。选择什么是最适合我的需要?请解释原因。谢谢!

I've briefly looked at options such as Shared Preferences, Internal Storage, and others. What option is the best for my needs? Please explain why. Thanks!

推荐答案

下面是说明...

共享preferences 是良好的存储...一个应用程序的preferences和数据等小位。这几个数据类型,只是一个非常简单的字符串持续密钥存储:布尔型,浮点型,整型,长字符串。因此,举例来说,如果我的应用程序有一个登录,我可能会考虑存储会话密钥共享preferences内的字符串。

Shared preferences are good for storing ... an application's preferences, and other small bits of data. It's a just really simple persistent string key store for a few data types: boolean, float, int, long and string. So for instance if my app had a login, I might consider storing the session key as string within SharedPreferences.

内部存储是良好的存储应用程序数据,用户并不需要访问,因为用户不能方便地访问内部存储。可能是很好的缓存,日志,其他的事情。凡是只有应用程序打算创建,读取,更新或删除。

Internal storage is good for storing application data that the user doesn't need access to, because the user cannot easily access internal storage. Possibly good for caching, logs, other things. Anything that only the app intends to Create Read Update or Delete.

外部存储。伟大的是我刚才说的相反。 Dropbox的应用程序可能使用外部存储来存储用户的Dropbox的文件夹,使用户拥有Dropbox的应用程序之外方便地访问这些文件,例如,使用文件管理器。

External storage. Great for the opposite of what I just said. The dropbox app probably uses external storage to store the user's dropbox folder, so that the user has easy access to these files outside the dropbox application, for instance, using the file manager.

SQLite数据库是伟大的,只要你有很多的结构化数据和用于管理其相对刚性架构。通俗地说说,SQLite是像MySQL或PostgreSQL除了没有作为一个服务器守护程序,然后需要由CGI脚本,如PHP的查询,它只是存储在.db文件,以及访问和通过一个简单的图书馆查询的数据库在应用程序中。虽然SQLite的无法形成规模几乎一样大的专用数据库,这是非常方便快捷的为小型应用程序,如Android应用。如果我将某个应用进行汇总和下载食谱,因为这类型的数据相对结构化和数据库将允许它具有良好的伸缩性,我会用一个SQLite数据库。数据库是不错的,因为所有数据写入一个文件,然后解析它放回自己的专有格式它没有乐趣。话又说回来,存储XML或JSON数据也不会这么糟糕。

SQLite databases are great whenever you a lot of structured data and a relatively rigid schema for managing it. Put in layman's terms, SQLite is like MySQL or PostgreSQL except instead of the database acting as a server daemon which then takes queries from the CGI scripts like php, it is simply stored in a .db file, and accessed and queried through a simple library within the application. While SQLite cannot scale nearly as big as the dedicated databases, it is very quick and convenient for smaller applications, like Android apps. I would use an SQLite db if I were making an app for aggregating and downloading recipes, since that kind of data is relatively structured and a database would allow for it to scale well. Databases are nice because writing all of your data to a file, then parsing it back in your own proprietary format it no fun. Then again, storing data in XML or JSON wouldn't be so bad.

网络连接指的是存储在云中的数据。通过java.net HTTP或FTP文件和内容传输。*包使这种情况发生。

Network connection refers to storing data on the cloud. HTTP or FTP file and content transfers through the java.net.* packages makes this happen.

  Considering this i suggest you to use Sqlite especially in your case.

最好的运气

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

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