android逐行写入读取
Android external storage can be used to write and save data, read configuration files etc. This article is continuation of the Android Internal Storage tutorial in the series of tutorials on structured data storage in android.
Android外部存储可用于写入和保存数据,读取配置文件等。本文是有关Android内部结构化数据存储的系列教程中Android内部存储教程的继续。
Android外部存储 (Android External Storage)
External storage such as SD card can also store application data, there’s no security enforced upon files you save to the external storage.
In general there are two types of External Storage:
SD卡等外部存储设备也可以存储应用程序数据,保存到外部存储设备的文件没有安全性要求。
通常,外部存储有两种类型:
- Primary External Storage: In built shared storage which is “accessible by the user by plugging in a USB cable and mounting it as a drive on a host computer”. Example: When we say Nexus 5 32 GB. 主要外部存储设备 :内置的共享存储设备,“用户可以通过插入USB电缆并将其作为驱动器安装在主机上进行访问”。 示例:当我们说Nexus 5 32 GB时。
- Secondary External Storage: Removable storage. Example: SD Card 辅助外部存储 :可移动存储。 示例:SD卡
All applications can read and write files placed on the external storage and the user can remove them. We need to check if the SD card is available and if we can write to it. Once we’ve checked that the external storage is available only then we can write to it else the save button would be disabled.
所有应用程序都可以读写放置在外部存储器上的文件,并且用户可以删除它们。 我们需要检查SD卡是否可用以及是否可以对其进行写入。 一旦检查完外部存储仅可用,就可以对其进行写入,否则将禁用保存按钮。
Android外部存储示例项目结构 (Android External Storage Example Project Structure)
Firstly, we need to make sure that the application has permission to read and write data to the users SD card, so lets open up