ContextWrapper contextWrapper = new ContextWrapper(getApplicationContext());
File directory = contextWrapper.getDir(filepath, 0);
File myInternalFile = new File(directory , "MySampleFile.txt");
//for writing
FileOutputStream fos = null;
try {
fos = new FileOutputStream(myInternalFile);
fos.write("data".toString().getBytes());
fos.close();
}
catch (FileNotFoundException e1) {
e1.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
//for reading
String myData="";
try {
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();
}
Toast.makeText(getApplicationContext(), myData, Toast.LENGTH_SHORT).show();//prints data
我可以读取和写入文件。 我想知道的是如何浏览到文件或查看文件? 使用的文件浏览器,但我以前不利于