其中Android的数据存储技术的使用? [英] Which Android Data Storage Technique to use?

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

问题描述

Android的文件有以下以下选项,但并不能说明什么情况下,每一个是最好的。什么是每种方法的利弊?例如在什么条件下SQL比共享preferences好?

The android documentation has the following options below but does not explain what circumstances each is best for. What are the pros and cons of each method? e.g. Under what conditions would SQL be better than Shared Preferences?

  • 共享preferences
  • 在内部存储
  • 在外部存储
  • 在SQLite数据库
  • 网络连接

推荐答案

Different Storage options in Android

  • 考虑添加到设备的结构化数据从应用1是 无法接触到另一个应用2 present在相同的设备,但 资料照片添加到设备通过应用程序1 是提供给 在应用2 在同一设备中运行

  • Consider the structured data added to the device from application1 is not accessible to another application2 present in the same device but the profile photo added to the device by application1 is available to the application2 running in the same device

考虑Android设备作为一个城市,在它的应用程序是 房子在城市,人们在房子(应用程序)的数据。 现在,内容提供商就像是在城市(Android设备)的经纪人。 该券商提供访问的人在城市寻找 不同的房子指为在Android的内容提供商 装置提供在该装置针对不同的接入为数据 应用程序。

Consider android device as a city, the applications in it are the houses in the city, people in the houses(application) are the data. Now content provider is like an broker in the city(android device). This broker provide access for the people in the city for finding different houses referring as the content provider in the android device provide access for the data in the device for different applications.

  • 假设我有一个应用程序说脸书应用程序,我用登录 我的帐户。

  • Consider I have an App say a Face book App which I use to log in to my account.

现在的我第一次进入我的用户名和密码来获得 访问我的帐户。说我退出了应用程序的一个小时后, 我再次使用相同的脸书应用程序再次登录到我的应用程序。

Now the very first time I enter my username and password to get access to my account. Say I log out of the application an hour later again I use the same Face book App to login again to my application.

我必须再次输入用户名和密码登录到我的帐户 我设定一个主题,我在我的应用程序是如何应用和其他设置 看起来现在的电话

I have to enter username and password again to login to my account and I set a theme to my application and other settings on how my app looks in my current phone

这是联合国必要的,因为考虑我用我的手机登录 应用程序。所以我会一直用我的手机再次登录并 再次,从而再次进入我的凭据,再次是更多的工作 说明它不是一个用户友好的应用程序

This is un-necessary because consider I am using my phone to login to the application. So I will always use my phone to login again and again, thus entering my credentials again and again is more work shows it’s not a user friendly app

共享preferences是非常方便的在这样的情况下,我可以用 它的功能在其中实际存在的xml文件共享数据 Android应用程序安装在我的手机,这是不是就算毁 应用程序被关闭。在这里,我们可以节省用户的preferences的数据 当前的应用程序。

Shared Preferences is very handy in such scenarios where I can use its feature to share my data in a xml file Which physically exists in the Android app installed in my phone which is not destroyed even if the app is closed. Here we can save user preferences data of the current application.

因此​​下一次我在我的手机打开我的应用程序,我可以看到的数据 自动填入必要的字段和设置

As a result next time I open my app in my phone I can see the data automatically filled in the necessary fields and the settings are

  • 在Android中,我们可以使用该设备的存储空间来存储数据 它的应用程序。数据的类型涉及的东西,如一个 文本文件,图像文件,视频文件,音频文件等。

  • In Android we can use the device storage space to store the data in it for the applications. The type of data involves things such as a text file, image file, video file, audio file etc.

如在图中可见,因为我们可以看到,有两个地方,我们可以 做这个。一种方法是写出原始文件到主/辅 存储。另一种方法是将缓存写入文件到 主要/次要存储。

As seen in the figure as we can see that there are two places we can do this. One way is to write the raw files into primary /secondary storage. Another way is to write the cache files into the primary/secondary storage.

还存储原始数据并缓存数据之间的差异, 一旦存储在存储器中由用户的原始数据必须是明确地 用户明确删除,否则会存在,直到然后。 存储在内存中缓存数据不会因为一个永久性数据 系统会自动删除它,如果它觉得有不足 内存。

There is also difference between storing raw data and the cache data, the raw data once stored in memory by user has to be explicitly deleted by the user explicitly otherwise it would exist till then. Cache data stored in memory is not a permanent data because the system automatically deletes it if it feels there is shortage of memory.

内部存储:

  • 考虑在应用程序中用户已经存储的数据在内部 该申请的存储,那么只有该用户有权访问该 在移动和该数据的数据被自动删除时 用户卸载应用程序。说到这的内部存储器 私有的。

  • Consider a user in an application has stored data in internal storage, then only that user of that application has access to that data on the mobile and that data is automatically deleted when the user uninstalls the application. Speaking of which internal memory is private.

在应用程序内部存储目录中使用的名称包存储 在Android文件系统的一个特殊的地方的名字。

The apps internal storage directory is stored using the name package name in a special place in the android file system.

其他应用程序或当前应用程序的用户必须通过设置文件无法访问 一个特定的用户和特定的应用程序,除非明确作出 可为可读/写访问的用户。

Other apps or users of current app have no access to the file set by a particular user and a particular app unless it is explicitly made available to the user for readable/writable access.

  • SQLite是用于在移动本地存储更多的结构化数据 其中,Android的应用程序正在运行。结构化数据包括作为 这在像在形式的学生的信息的图示 行和列。

  • Sqlite is used to store more structured data locally in a mobile where the android app is running. Structured data involves as of which shown in the figure like a student’s information in the form of rows and columns.

sqlite的提供了类似的功能,例如MySQL和Oracle但 有限的功能特性。一些事涉及执行 表上的查询操作。有特色,虽然像创建 意见还有些功能无法使用像存储过程。

Sqlite offers similar functionality like Mysql and oracle but with limited functional features. Some of the things involve performing query operations on tables. There are features though like creating views but also some features are not available like stored procedure.

SQLite是在存储复杂而庞大的数据,可以是非常有益 下载一次并可以反复使用,直到应用程序 在跑。当应用程序被关闭SQLite数据库是 也摧毁了。

Sqlite is very helpful in storing complex and large data which can be downloaded once and can be used again and again until the application is running. When the application is closed the sqlite database is also destroyed.

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

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