String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
Log.d("list",TextUtils.join(",", values));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
String a="hi is";
File myFile = new File("/sdcard/mysdcardfile.txt");
try {
myFile.createNewFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
//byte[] anotherArray = new byte[values.length];
byte data[] = new byte[1024];
int count;
long total = 0;
FileOutputStream output = new FileOutputStream(myFile);
while ((count = values.length) != -1) {
total += count;
// FileWriter fos = new FileWriter(myFile);
// BufferedWriter bis = new BufferedWriter(fos);
output.write(data, 0, count);
//bis.close();
//fos.close();
output.close();
}
這裏我的值以文本格式存儲在我的SD卡中,但是當我打開文本文件時,它包含bytes.here這些值存儲在byte.how中,當我寫入fileoutputstrem時將字節更改爲字符串我想獲取文本文件中的值。如何使用文本格式將字符串數組保存在SD卡中?
如何更改我的代碼? – Rajesh 2012-07-18 08:45:30
包含從文件讀取的代碼。 – AAnkit 2012-07-18 08:54:28