SharedPreference是一种轻量型的数据存储方式,它的本质是基于XML文件存储Key-Value键值对数据,通常用来存储一些简单的配置信息。其存储位置在/data/data/<包名>/
shared_prefs目录下。 SharedPreference对象本身只能获取数据而不支持存储和修改,存储修改是通过Editor对象实现。
代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems=&