我正在使用 Android 1.5 我的数据目录没有读/写权限
System.out.println("DAta can write??--->"+Environment.getDataDirectory().canWrite());
System.out.println("DAta can read??--->"+Environment.getDataDirectory().canRead());
所以请建议我如何为数据目录提供权限。
我要做的是创建一个文件并在模拟器的数据存储中添加一些内容,如下所示
private void writeToSDCard() {
try {
File lroot = Environment.getDataDirectory();
if (lroot.canWrite()){
File lfile = new File(lroot, "samplefile.txt");
FileWriter lfilewriter = new FileWriter(lfile);
BufferedWriter lout = new BufferedWriter(lfilewriter);
lout.write("XXXXXXXXXXXXXXXXXX");
lout.close();
}
} catch (IOException e) {
Log.e(m_cTAG, "Could not write file " + e.getMessage());
}
}