0
我决定使用内部存储器将文件保存到文件夹中。我的代码是:访问在内部存储器中创建的文件
File dir = new File (getFilesDir(), "myFolder");
dir.mkdirs();
File file = new File(dir, "myData.txt");
try {
FileOutputStream f = new FileOutputStream(file);
PrintWriter pw = new PrintWriter(f);
pw.println("Hi");
pw.println("Hello");
pw.flush();
pw.close();
f.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
tv.append("\n\nFile written to "+file);
显示的目录是数据/数据/包/文件/ MyFolder中/ myData.txt 不过,我想检查文件是否包含输入的字符串,但我似乎无法找到创建的文件在哪里。我试图输出文件的内容,但我失败了。我知道这听起来很荒谬。我想要做的是检查内容并知道文件是否被创建。任何人都可以帮忙吗?
OK,谢谢!有没有办法手动找到并检查创建的文件的内容? – chArm 2013-02-19 18:38:00