Fork me on GitHub

【Android學習專題】数据存储篇:SharedPreferences/Files/SDCard

 


【Android学习专题】数据存储篇:SharedPreferences/Files/SDCard

   SkySeraph Feb 2nd 2012  SZTCL

Email:zgzhaobo@gmail.com    QQ:452728574


-----------------------------------------------------------------------------------------------------------------------------------------------------------

【数据存储概述 】

Ⅰ Android的5种方式存储数据

  1.使用SharedPreferences存储数据;

  2.使用Files存储数据;

  3.使用SQLite数据库存储数据;

  4.使用ContentProvider存储数据;

  5.网络存储数据;

Ⅱ 测试界面

 ----------------------------------------------------------------------------------------------------------------------------------------------------------

【SharedPreferences】

Ⅰ 概述:用来存储"Key"-"Value"格式的数据,主要针对系统配置信息的保存,如用户登录时,输入了用户名密码,下次登录时保留这一次的输入内容。

Ⅱ 操作

* 1 存:

  *  SharedPreferences mPre = Context.getPreferences(0); // 取得活动的preferences对象

  *  SharedPreferences.Editor editor = mPre.edit();  // 取得编辑对象

  *  editor.putString(KEY, value);       // 添加值  

  *  editor.putBoolean(KEY, value);  

  *  editor.commit();         // 提交保存

* 2 取:  

  *  SharedPreferences mPre = getPreferences(Activity.MODE_PRIVATE); // 取得活动的preferences对象  

  *  String value = mPre.getString(KEY, "默认值");      // 取得值  

  *  Boolean value = mPre.getBoolean(KEY, false);  

* 3 存取时间:主要有下面三种情况,其它也可以根据实际来操作  

  *  protected void onPause() //系统通知暂停,可以保存设置  

  *  public void onDestroy()  //系统通知关闭,可以保存设置  

  *  public void onCreate(Bundle savedInstanceState) //系统启动,可以打开设置  

* 4 保存:  

  * ①保存后生成的是XML文件,内容是以节点的形势保存在文件中  

  * ②位置:/data/data/package/shared_prefs  

  * ③权限:本地程序所拥有,其它程序无法获得操作,无法实现共享

Ⅲ 常用方法参考

 

Ⅳ 实例源码

1 java源码

View Code
 1 public class preference extends Activity
2 {
3 // //////////////////////////////////////////////////////////////////////////////
4 private EditText mEditText;
5 private Button mBtn1, mBtn2, mBtn3;
6 private static final String DATASTORAGE_Preference_FILE_NAME="preferenceTest"; //SharedPreferences名称
7 public final static String DATASTORAGE_Preference_TEXT = "sms_content"; //存储信息
8 public final static String DATASTORAGE_Preference_FILE_URL = "/data/data/"; //SharedPreferences中储存数据的路径
9 public final static String DATASTORAGE_Preference_XML = "text.xml"; //
10 SharedPreferences mPre = null; //SharedPreferences对象
11
12 // //////////////////////////////////////////////////////////////////////////////
13 @Override
14 protected void onCreate(Bundle savedInstanceState)
15 {
16 // TODO Auto-generated method stub
17 super.onCreate(savedInstanceState);
18 setContentView(R.layout.mydatastorage_preference); // 设置Activity界面
19
20 // ①获得SharePreferences实例
21 mPre = getSharedPreferences(DATASTORAGE_Preference_FILE_NAME,this.MODE_PRIVATE);//参数含义:文件名、操作模式(私有、可读、可写)
22 // ②从SharePreferences中获得短信内容
23 String content = mPre.getString(DATASTORAGE_Preference_TEXT, "没编入信息");
24 // 从EditText中显示短信内容
25 //mEditText.setText(content);
26
27 // 通过findViewById方法实例化对象
28 mEditText = (EditText) findViewById(R.id.mydatastorage_preference_ET01);
29 mEditText.setHint("上次编入的短信内容为:"+content);
30
31 mBtn1 = (Button) findViewById(R.id.preference_Btn01);
32 mBtn1.setOnClickListener(new OnClickListener()//Read
33 {
34 @Override
35 public void onClick(View v)
36 {
37 // TODO Auto-generated method stub
38 String name = mEditText.getText().toString(); //获得数据
39 Editor editor = mPre.edit();//获得编辑器
40 editor.putString(DATASTORAGE_Preference_TEXT, name); //保存入SharedPreferences
41 editor.commit(); //put完毕必需要commit()否则无法保存
42 }
43 });
44 mBtn2 = (Button) findViewById(R.id.preference_Btn02);
45 mBtn2.setOnClickListener(new OnClickListener()//clear
46 {
47 @Override
48 public void onClick(View v)
49 {
50 Editor editor = mPre.edit();
51 editor.remove(DATASTORAGE_Preference_TEXT);
52 editor.clear();
53 editor.commit();
54 }
55 });
56 mBtn3 = (Button) findViewById(R.id.preference_Btn03);
57 mBtn3.setOnClickListener(new OnClickListener()//delete
58 {
59 @Override
60 public void onClick(View v)
61 {
62 File file = new File(DATASTORAGE_Preference_FILE_URL + getPackageName().toString()
63 + "/shared_prefs", DATASTORAGE_Preference_XML);
64 if (file.exists())
65 {
66 file.delete();
67 }
68 }
69 });
70 }
71 // //////////////////////////////////////////////////////////////////////////////
72 }

2 XML配置文件

View Code
 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:orientation="vertical" >
6
7 <TextView
8 android:layout_width="fill_parent"
9 android:layout_height="wrap_content"
10 android:text="Preference Test"
11 android:textSize="25dp" />
12
13 <EditText
14 android:id="@+id/mydatastorage_preference_ET01"
15 android:layout_width="fill_parent"
16 android:layout_height="wrap_content"
17 android:height="180px"
18 android:text="" >
19 </EditText>
20
21 <LinearLayout
22 android:layout_width="fill_parent"
23 android:layout_height="wrap_content" >
24
25 <Button
26 android:id="@+id/preference_Btn01"
27 android:layout_width="wrap_content"
28 android:layout_height="wrap_content"
29 android:text="Read" >
30 </Button>
31
32 <Button
33 android:id="@+id/preference_Btn02"
34 android:layout_width="wrap_content"
35 android:layout_height="wrap_content"
36 android:text="Clear" >
37 </Button>
38
39 <Button
40 android:id="@+id/preference_Btn03"
41 android:layout_width="wrap_content"
42 android:layout_height="wrap_content"
43 android:text="Delete" >
44 </Button>
45
46 </LinearLayout>
47
48 </LinearLayout>

Ⅴ 效果

-----------------------------------------------------------------------------------------------------------------------------------------------------------

【Files】

Ⅰ 应用:文件存储(应用程序内存中)。

Ⅱ 操作  

* 1 写入:FileOutputStream fos = openFileOutput(FILE_NAME, Context.MODE_PRIVATE);(如果文件不存在会自动创建)  

*   fos.write(str);  

* 2 读取:FileInputStream fis = openFileInput(FILE_NAME);  

*   fis.read(buf);  

* 3 清除:采用写入空str的方式  

* 4 删除:super.deleteFile(FILE_NAME);

Ⅲ 常用方法

Ⅳ 实例源码

1 java源码

  1 public class files extends Activity
2 {
3 // 文件名字符串常量
4 private static final String DATASTORAGE_FILE_FILE_NAME="filesTest.txt";
5 // file中储存数据的路径
6 public final static String DATASTORAGE_FILE_FILE_URL = "/data/data/";
7 // 按钮和编辑框对象
8 private Button mBtn1,mBtn2,mBtn3,mBtn4;
9 private EditText mEt1,mEt2;
10
11 @Override
12 protected void onCreate(Bundle savedInstanceState)
13 {
14 // TODO Auto-generated method stub
15 super.onCreate(savedInstanceState);
16 setContentView(R.layout.mydatastorage_files);
17
18 String content = readFile(DATASTORAGE_FILE_FILE_NAME);
19 if (TextUtils.isEmpty(content))
20 {
21 content = "上次输入内容为空,请输入内容!";
22 }
23 String str2 = "上次输入的内容为("+content+")";
24 String str1 = "请在此输入内容!";
25
26 mEt1 = (EditText)findViewById(R.id.mydatastorage_files_ET01);
27 mEt1.setHint(str1);
28 mEt2 = (EditText)findViewById(R.id.mydatastorage_files_ET02);
29 mEt2.setHint(str2);
30
31 mBtn1 = (Button)findViewById(R.id.mydatastorage_files_Btn01);
32 mBtn2 = (Button)findViewById(R.id.mydatastorage_files_Btn02);
33 mBtn3 = (Button)findViewById(R.id.mydatastorage_files_Btn03);
34 mBtn4 = (Button)findViewById(R.id.mydatastorage_files_Btn04);
35
36 mBtn1.setOnClickListener(new OnClickListener()//写入
37 {
38 @Override
39 public void onClick(View v)
40 {
41 String content = mEt1.getText().toString();
42 saveToFile(DATASTORAGE_FILE_FILE_NAME,content,5);
43 showInfo("写入成功");
44 }
45 });
46
47 mBtn2.setOnClickListener(new OnClickListener()//读取
48 {
49 @Override
50 public void onClick(View v)
51 {
52 String content = readFile(DATASTORAGE_FILE_FILE_NAME);
53 mEt2.setText(content);
54 showInfo("读取成功");
55 }
56 });
57
58 mBtn3.setOnClickListener(new OnClickListener()//清除
59 {
60 @Override
61 public void onClick(View v)
62 {
63 clearFile(DATASTORAGE_FILE_FILE_NAME);
64 String content = readFile(DATASTORAGE_FILE_FILE_NAME);
65 mEt2.setText(content);
66 showInfo("清除成功");
67 }
68 });
69
70 mBtn4.setOnClickListener(new OnClickListener()//删除
71 {
72 @Override
73 public void onClick(View v)
74 {
75 deleteSDFile(DATASTORAGE_FILE_FILE_NAME);
76 }
77 });
78 }
79
80 // ////////////////////////////////////////////////////////////////////////////////////
81 /* 文件写入(文件保存至手机File) */
82 public void saveToFile(String filename, String content, int method)
83 {
84 try
85 {
86 FileOutputStream fos = null;
87 switch (method)
88 {
89 case 1:// MODE_PRIVATE
90 // ①以默认私有方式保存文件内容,存放在手机存储空间中(Context.MODE_PRIVATE)
91 fos = this.openFileOutput(filename, this.MODE_PRIVATE);// 获取输出流
92 break;
93 case 2:// MODE_APPEND
94 // ②以追加的方式保存文件内容 (Context.MODE_APPEND)
95 fos = this.openFileOutput(filename, this.MODE_APPEND);
96 break;
97 case 3:// MODE_WORLD_READABLE
98 // ③以允许其他应用从该文件中读取内容的方式保存文件(Context.MODE_WORLD_READABLE)
99 fos = this.openFileOutput(filename, this.MODE_WORLD_READABLE);
100 break;
101 case 4:// MODE_WORLD_WRITEABLE
102 // ④以允许其他应用往该文件写入内容的方式保存文件(Context.MODE_WORLD_WRITEABLE)
103 fos = this.openFileOutput(filename, this.MODE_WORLD_WRITEABLE);
104 break;
105 case 5:// MODE_WORLD_READABLE + MODE_WORLD_WRITEABLE
106 // ⑤以允许其他应用对该文件读和写的方式保存文件(MODE_WORLD_READABLE与MODE_WORLD_WRITEABLE)
107 fos = this.openFileOutput(filename, this.MODE_WORLD_READABLE
108 + this.MODE_WORLD_WRITEABLE);
109 break;
110 default:
111 fos = this.openFileOutput(filename, this.MODE_PRIVATE);
112 break;
113 }
114 fos.write(content.getBytes());
115 fos.close();
116
117 } catch (FileNotFoundException e)
118 {
119 e.printStackTrace();
120 } catch (IOException e)
121 {
122 e.printStackTrace();
123 }
124 }
125 // ////////////////////////////////////////////////////////////////////////////////////
126 /*清除记录 */
127 public void clearFile(String filename)
128 {
129 String cleanStr = "";
130 try
131 {
132 FileOutputStream outStream = this
133 .openFileOutput(filename, this.MODE_WORLD_READABLE);
134 outStream.write(cleanStr.getBytes());
135 outStream.close();
136 } catch (FileNotFoundException e)
137 {
138 } catch (IOException e)
139 {
140 }
141 }
142 // ////////////////////////////////////////////////////////////////////////////////////
143 /* 文件删除 */
144 public void deleteSDFile(String filename)
145 {
146 File file = new File(DATASTORAGE_FILE_FILE_URL + getPackageName().toString()
147 + "/files", filename);
148 if (file.exists())
149 {
150 file.delete();
151 }
152 showInfo("删除成功");
153 }
154 // ////////////////////////////////////////////////////////////////////////////////////
155 /*文件读取(文件加载)*/
156 public String readFile(String filename)
157 {
158 try
159 {
160 // 实例化文件输入流对象
161 FileInputStream inStream = this.openFileInput(filename);
162 // 定义缓存数组
163 byte[] buffer = new byte[inStream.available()];
164 // 读到缓存区
165 inStream.read(buffer);
166 inStream.close();
167 return new String(buffer);
168 } catch (FileNotFoundException e)
169 {
170 e.printStackTrace();
171 } catch (IOException e)
172 {
173 e.printStackTrace();
174 }
175 return null;
176 }
177
178 // ////////////////////////////////////////////////////////////////////////////////////
179 /*显示子函数*/
180 private void showInfo(String str)
181 {
182 // new AlertDialog.Builder(files.this).setMessage(str).show();
183 Toast.makeText(files.this, str, Toast.LENGTH_LONG).show();
184 }
185 // ////////////////////////////////////////////////////////////////////////////////////
186
187 }

2 xml布局文件

View Code
 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:orientation="vertical" >
6
7 <TextView
8 android:layout_width="fill_parent"
9 android:layout_height="wrap_content"
10 android:text="Files Test"
11 android:textSize="25dp" />
12
13 <EditText
14 android:id="@+id/mydatastorage_files_ET01"
15 android:layout_width="fill_parent"
16 android:layout_height="wrap_content"
17 android:height="100px"
18 android:text="" >
19 </EditText>
20
21 <LinearLayout
22 android:layout_width="fill_parent"
23 android:layout_height="wrap_content" >
24
25 <Button
26 android:id="@+id/mydatastorage_files_Btn01"
27 android:layout_width="wrap_content"
28 android:layout_height="wrap_content"
29 android:text="Write" >
30 </Button>
31
32 <Button
33 android:id="@+id/mydatastorage_files_Btn03"
34 android:layout_width="wrap_content"
35 android:layout_height="wrap_content"
36 android:text="Clear Write" >
37 </Button>
38
39 </LinearLayout>
40
41 <EditText
42 android:id="@+id/mydatastorage_files_ET02"
43 android:layout_width="fill_parent"
44 android:layout_height="wrap_content"
45 android:height="100px"
46 android:text="" >
47 </EditText>
48
49 <LinearLayout
50 android:layout_width="fill_parent"
51 android:layout_height="wrap_content" >
52
53 <Button
54 android:id="@+id/mydatastorage_files_Btn02"
55 android:layout_width="wrap_content"
56 android:layout_height="wrap_content"
57 android:text="Read" >
58 </Button>
59
60 <Button
61 android:id="@+id/mydatastorage_files_Btn04"
62 android:layout_width="wrap_content"
63 android:layout_height="wrap_content"
64 android:text="Delete file" >
65 </Button>
66 </LinearLayout>
67
68 </LinearLayout>

Ⅴ 实例效果

-----------------------------------------------------------------------------------------------------------------------------------------------------------

【SDCard】

Ⅰ 应用:文件存储(SD卡中)。

Ⅱ 操作:  

* 1 在AndroidManifest文件中加入sdcard操作权限  

*  <!--在SDCard中创建与删除文件权限 -->  

*  <uses-permissioandroid:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>  

*  <!--往SDCard写入数据权限 -->  

*  <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  

* 2 确认sdcard的存在  

*  android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)  

* 3 获取扩展存储设备的文件目录  

*  android.os.Environment.getExternalStorageDirectory();

Ⅲ 常用方法参考

Ⅳ 实例源码

1 java源码

  1 public class sdcard extends Activity
2 {
3 // 文件名字符串常量和目录
4 public final static String DATASTORAGE_SDCard_FILE_NAME = "sdcardTest.txt";
5 // 按钮和编辑框对象
6 private Button mBtn1, mBtn2, mBtn3, mBtn4;
7 private EditText mEt;
8
9 @Override
10 protected void onCreate(Bundle savedInstanceState)
11 {
12 // TODO Auto-generated method stub
13 super.onCreate(savedInstanceState);
14 setContentView(R.layout.mydatastorage_sdcard);
15
16 String content = readSDCard(DATASTORAGE_SDCard_FILE_NAME);
17 if (TextUtils.isEmpty(content))
18 {
19 content = "上次输入内容为空,请输入内容!";
20 }
21
22 mEt = (EditText) findViewById(R.id.mydatastorage_sdcard_ET01);
23 mEt.setHint("上次输入SD卡的内容的为:"+content );
24
25 mBtn1 = (Button) findViewById(R.id.mydatastorage_sdcard_Btn01);
26 mBtn2 = (Button) findViewById(R.id.mydatastorage_sdcard_Btn02);
27 mBtn3 = (Button) findViewById(R.id.mydatastorage_sdcard_Btn03);
28 mBtn4 = (Button) findViewById(R.id.mydatastorage_sdcard_Btn04);
29
30 mBtn1.setOnClickListener(new OnClickListener()// 写入
31 {
32 @Override
33 public void onClick(View v)
34 {
35 String content = mEt.getText().toString();
36 saveToSDCard(DATASTORAGE_SDCard_FILE_NAME, content);
37 }
38 });
39 mBtn2.setOnClickListener(new OnClickListener()// 读取
40 {
41 @Override
42 public void onClick(View v)
43 {
44 String content = readSDCard(DATASTORAGE_SDCard_FILE_NAME);
45 if(TextUtils.isEmpty(content))
46 showInfo("读取文件为空!");
47 mEt.setText(content);
48 }
49 });
50
51 mBtn3.setOnClickListener(new OnClickListener()// 清除
52 {
53 @Override
54 public void onClick(View v)
55 {
56 clearSDFile(DATASTORAGE_SDCard_FILE_NAME);
57 String content = readSDCard(DATASTORAGE_SDCard_FILE_NAME);
58 mEt.setText(content);
59 }
60 });
61
62 mBtn4.setOnClickListener(new OnClickListener()// 删除
63 {
64 @Override
65 public void onClick(View v)
66 {
67 deleteSDFile(DATASTORAGE_SDCard_FILE_NAME);
68 }
69 });
70 }
71
72 // ////////////////////////////////////////////////////////////////////////////////////
73 /* 文件写入(文件保存到SDCard中) */
74 public void saveToSDCard(String filename, String content)
75 {
76 try
77 {
78 // Log.d(LOG_TAG, "Start Write");
79 // ①获取扩展SD卡设备状态
80 String SDCardState = android.os.Environment.getExternalStorageState();
81 if (SDCardState.equals(android.os.Environment.MEDIA_MOUNTED)) // 判断sdcard是否存在(可读可写权限)
82 {
83 // ②获取扩展存储设备的文件目录
84 File SDFile = android.os.Environment.getExternalStorageDirectory();
85 // ③打开文件
86 // File file = new File(SDFile,filename);
87 File file = new File(SDFile.getAbsolutePath() + File.separator + filename);
88 // 判断是否存在,不存在则创建
89 if (!file.exists())
90 {
91 file.createNewFile();
92 }
93 // ④写数据
94 FileOutputStream fos = new FileOutputStream(file); // 获取输出流
95 fos.write(content.getBytes());
96 fos.close();
97 showInfo("文件写入成功!");
98 } else
99 {
100 showInfo("文件写入失败!");
101 }
102
103 } catch (FileNotFoundException e)
104 {
105 e.printStackTrace();
106 } catch (IOException e)
107 {
108 e.printStackTrace();
109 }
110 }
111
112
113 // ////////////////////////////////////////////////////////////////////////////////////
114 /* 文件读取(文件加载) */
115 public String readSDCard(String filename)
116 {
117 try
118 {
119 String SDCardState = android.os.Environment.getExternalStorageState();
120 if (SDCardState.equals(android.os.Environment.MEDIA_MOUNTED)) // 只读权限
121 {
122 // 获取扩展存储设备的文件目录
123 File SDFile = android.os.Environment.getExternalStorageDirectory();
124 // 创建一个文件
125 File file = new File(SDFile.getAbsolutePath() + File.separator + filename);
126 // 判断文件是否存在
127 if (file.exists())
128 {
129 // 读数据
130 FileInputStream fis = new FileInputStream(file);
131 byte[] buffer = new byte[1024];// 定义缓存数组
132 // byte[] buffer = new byte[fis.available()];
133 fis.read(buffer);// 读到缓存区
134 fis.close();
135 showInfo("文件读取成功!");
136 return new String(buffer);
137 }
138 else
139 {
140 showInfo("文件不存在,读取失败!");
141 return null;
142 }
143 }
144 else
145 {
146 showInfo("无操作权限,文件读取失败!");
147 return null;
148 }
149 } catch (FileNotFoundException e)
150 {
151 e.printStackTrace();
152 } catch (IOException e)
153 {
154 e.printStackTrace();
155 }
156 return null;
157 }
158
159 // ////////////////////////////////////////////////////////////////////////////////////
160 // ////////////////////////////////////////////////////////////////////////////////////
161 /* 清除记录 */
162 public void clearSDFile(String filename)
163 {
164 String cleanStr = "";// 如果只须要删除文件中的一部分内容则须要在这里对字符串做一些操作
165 FileOutputStream fos = null;
166 File file = new File(Environment.getExternalStorageDirectory(),
167 filename);
168 try
169 {
170 fos = new FileOutputStream(file);
171 fos.write(cleanStr.getBytes());
172 fos.close();
173 } catch (FileNotFoundException e)
174 {
175 e.printStackTrace();
176 } catch (IOException e)
177 {
178 e.printStackTrace();
179 }
180 }
181
182 // ////////////////////////////////////////////////////////////////////////////////////
183 /* 文件删除 */
184 public void deleteSDFile(String filename)
185 {
186 String path = Environment.getExternalStorageDirectory() + "/"
187 + filename;
188 File file = new File(path);
189 boolean isDelte = file.delete();
190 if (isDelte)
191 {
192 showInfo("删除SD卡成功");
193 } else
194 {
195 finish();
196 }
197 }
198
199 // ////////////////////////////////////////////////////////////////////////////////////
200 /* 显示子函数 */
201 private void showInfo(String str)
202 {
203 // new AlertDialog.Builder(sdcard.this).setMessage(str).show();
204 Toast.makeText(sdcard.this, str, Toast.LENGTH_LONG).show();
205 }
206 // ////////////////////////////////////////////////////////////////////////////////////
207 }

2 xml布局文件

 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:orientation="vertical" >
6
7 <TextView
8 android:layout_width="fill_parent"
9 android:layout_height="wrap_content"
10 android:text="SDCard Test"
11 android:textSize="25dp" />
12
13 <EditText
14 android:id="@+id/mydatastorage_sdcard_ET01"
15 android:layout_width="fill_parent"
16 android:layout_height="wrap_content"
17 android:height="200px">
18 </EditText>
19
20 <LinearLayout
21 android:layout_width="fill_parent"
22 android:layout_height="wrap_content" >
23
24 <Button
25 android:id="@+id/mydatastorage_sdcard_Btn01"
26 android:layout_width="wrap_content"
27 android:layout_height="wrap_content"
28 android:text="Write" >
29 </Button>
30
31 <Button
32 android:id="@+id/mydatastorage_sdcard_Btn02"
33 android:layout_width="wrap_content"
34 android:layout_height="wrap_content"
35 android:text="Read" >
36 </Button>
37
38 <Button
39 android:id="@+id/mydatastorage_sdcard_Btn03"
40 android:layout_width="wrap_content"
41 android:layout_height="wrap_content"
42 android:text="Clear" >
43 </Button>
44
45 <Button
46 android:id="@+id/mydatastorage_sdcard_Btn04"
47 android:layout_width="wrap_content"
48 android:layout_height="wrap_content"
49 android:text="Delete" >
50 </Button>
51 </LinearLayout>
52
53 </LinearLayout>

Ⅴ 实例效果

-----------------------------------------------------------------------------------------------------------------------------------------------------------

Refs:

1 http://blog.csdn.net/jiahui524

2 http://blog.csdn.net/xys289187120/article/details/6645629

3 http://www.moandroid.com/?p=319

4 http://blog.csdn.net/rhljiayou/article/details/7100840



posted @ 2012-03-04 23:47  SkySeraph  阅读(3963)  评论(0编辑  收藏  举报