知识:
Content类中提供了一个openFileOutput()方法,可以用于将数据存储到指定的文件夹中。这个方法接受两个参数,第一个是文件名,文件默认存储到/data/data/package name/files目录中。第二个是文件的操作模式,主要有MODE_PTIVATE和MODE_APPEND。
示例:
1、在android studio 中创建一个FileStorageTest项目。
2、创建完成后修改activity_main.xml中的代码。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/edtData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="输入要保存的数据"/