如何从内部存储中读取文本文件并将其显示在textview中?
所以就是这种情况,在第二个活动中我有两个edittext将输入数据保存到两个单独的文件中。我想检索这些文件并在单独的文本视图中显示单独的内容。
public void refreshHandler(View view)
{
TextView textView7 = (TextView) findViewById(R.id.textView7);
TextView textView8 = (TextView) findViewById(R.id.textView8);
String myData = "";
try {
File myInternalFile = (Names.txt);
FileInputStream fis = new FileInputStream(myInternalFile);
DataInputStream in = new DataInputStream(fis);
BufferedReader br = new BufferedReader(new
InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
myData = myData + strLine;
}
in.close();
}
catch (IOException e) { e.printStackTrace();
}
textView7.setText(myData);
textView8.setText(myData);
}