Android 数据存储
2010-04-10 04:46:00 来源:WEB开发网37. android:layout_width="fill_parent"
38. android:layout_height="wrap_content"
39. android:password="true"
40. android:text=""
41. >
42. < /EditText>
43. < /LinearLayout>
< ?xml version="1.0" encoding="utf-8"?> < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > < TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="SharedPreferences demo" / > < TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="name" > < /TextView> < EditText android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" > < /EditText> < TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="password" > < /TextView> < EditText android:id="@+id/password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:password="true" android:text="" > < /EditText> < /LinearLayout>
主要实现代码
view plaincopy to clipboardprint?
1. package com.demo;
2.
3. import android.app.Activity;
4. import android.content.SharedPreferences;
5. import android.os.Bundle;
6. import android.widget.EditText;
7.
8. public class SharedPreferencesDemo extends Activity {
9.
10. public static final String SETTING_INFOS = "SETTING_Infos";
11. public static final String NAME = "NAME";
12. public static final String PASSWORD = "PASSWORD";
13. private EditText field_name; //接收用户名的组件
14. private EditText filed_pass; //接收密码的组件
更多精彩
赞助商链接