我有写这个代码,并读取文件ZIZI.txt:如何在没有root权限的情况下访问写入的文件?
//=============== Write To File ZIZI.txt ===============================================
private void writeFileToInternalStorage() {
String eol = System.getProperty("line.separator");
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(openFileOutput(
"ZIZI.txt", MODE_WORLD_WRITEABLE)));
writer.write("This is a test1." + eol);
writer.write("This is a test2." + eol);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Toast.makeText(getBaseContext(),"OK Save", Toast.LENGTH_SHORT).show();
}
//================ Read From File ZIZI.txt ===========================================
private void readFileFromInternalStorage() {
String FF="";
String eol = System.getProperty("line.separator");
BufferedReader input = null;
try {
input = new BufferedReader(new InputStreamReader(openFileInput("ZIZI.txt")));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = input.readLine()) != null) {
FF+=line+eol;
buffer.append(line + eol);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Toast.makeText(getBaseContext(),FF, Toast.LENGTH_SHORT).show();
}
我DDMS该文件中看到:\data\data\setup.myProject\files\ZIZI.txt
但我不能看到这个文件我手机(因为我没有root权限)
我想写我的SD卡或从我的 手机中看到的任何文件夹中读取。如何更改此代码?
也许你想要一个应用程序,让你看到所有文件夹(文件系统),包括根? – 2012-03-30 18:41:18
我只需要知道什么改变我的代码,我可以写入和阅读文件夹,我可以在手机上看到 – Gold 2012-03-30 19:00:54