首页 > 代码库 > SharedPreferences作业
SharedPreferences作业
安卓作业:
使用SharedPreference将姓名和年龄信息保存到文件,然后再读取
1.主要xml文件代码:
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入姓名:"/>
<EditText
android:id="@+id/age"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入年龄:"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/write"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="写入"/>
<Button
android:id="@+id/read"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="读取" />
</LinearLayout>
2.java部分代码
SharedPreferences作业