SD カードの txt ファイルに書き込んだ内容をログで読み取ることはできますが、ファイルを開くことができません。onClick を txt ビューアーまたはその他のファイルで開く必要があります。次の方法で、今すぐログに値を表示できます。
public void onClick(View v)
{
File file = new File("/sdcard/ReportData.txt");
StringBuffer contents = new StringBuffer();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String text = null;
// repeat until all lines is read
while ((text = reader.readLine()) != null) {
contents.append(text)
.append(System.getProperty(
"line.separator"));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Log.e("TEXT", contents.toString());
}
しかし、私はファイルを開くことができません..どうすればできますか?