android逐行写入读取_Android外部存储-读取,写入,保存文件

本文介绍了如何在Android外部存储(如SD卡)上进行读写操作,包括主要和辅助外部存储的区别,以及检查外部存储可用性的方法。通过示例代码展示了如何在Android应用中实现文件的保存和读取,同时强调了使用getExternalFilesDir()方法来存储应用相关文件,并在卸载应用后这些文件会被删除。
摘要由CSDN通过智能技术生成

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值