您好我通过将String ArrayList写入文件和阅读来解决同样的问题。
这是我的写作代码
File SettingsPath = getFilesDir();
String strSettingsPath = SettingsPath.toString() + "/settings.txt";
File file = new File (strSettingsPath);
if (!file.exists()) {
File removeFile = new File(strSettingsPath.toString());
boolean deleted = removeFile.delete();
}
try {
FileOutputStream fos =
new FileOutputStream(
new File(strSettingsPath));
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(this.strSettings);
os.close();
Log.v("","File has been written");
} catch(Exception ex) {
ex.printStackTrace();
}
这是阅读
public void reader(View v) throws FileNotFoundException {
File SettingsPath = getFilesDir();
String strSettingsPath = SettingsPath.toString() + "/settings.txt";
List<String> Settings = new ArrayList<String>();
BufferedReader readerL = new BufferedReader(new FileReader(strSettingsPath));
String line;
try{
//line = readerL.readLine();
while ((line = readerL.readLine()) != null) {
Settings.add(line);
System.out.println("The Setting line is " + Settings);
}
readerL.close();
}catch (IOException e){
e.printStackTrace();
}
通过阅读我得到了这个
设定行是[����sr��java.util.ArrayListx����a���I��sizexp������w������t��] 设置行是[����sr��java.util.ArrayListx����a���I��sizexp������w������t��,test @ test。 comt��passwordt��itdguccgjx]
我需要这样
test@test.com 密码 itdguccgjx
有什么问题?
抱歉我的英语不好。
您好
我会喜欢这个。
Textbox1的 TextBox2中 Textbox3
.......
如果我得到arraylist.get(1).tostring的值,我会得到Textbox2