Android中想要存储一部分数据在文件中,数据量不会很大,因为文件最终也是存储在手机内存中,数据量太大,则会导致文件的体积增大。
采用文件存储的方式存储数据,实际上与Java对文件读写是一样的操作,字符流读写、字节流读写均可。如果你java关于文件操作学得还不错,这部分可以直接跳过。
第1步:布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="展示信息" />
<