是否可以将SD卡中现有目录/文件的权限设置为只读,这意味着它不能被用户删除?
FileConnection有 setWritable()。我尝试使用它,但仍然没有运气。
FileConnection fconn = null;
try {
fconn = (FileConnection) Connector.open("file:///SDCard/BlackBerry/documents/TestDirectory/", Connector.READ_WRITE);
if (!fconn.exists()) fconn.mkdir();
// copyFile is taken from http://supportforums.blackberry.com/t5/Java-Development/copy-file/td-p/265877
copyFile("file:///SDCard/BlackBerry/documents/test.pdf","file:///SDCard/BlackBerry/documents/TestDirectory/test.pdf");
copyFile("file:///SDCard/BlackBerry/documents/data1.txt","file:///SDCard/BlackBerry/documents/TestDirectory/data1.txt");
copyFile("file:///SDCard/BlackBerry/music/gaudeamus.mp3","file:///SDCard/BlackBerry/documents/TestDirectory/gaudeamus.mp3");
fconn = (FileConnection) Connector.open("file:///SDCard/BlackBerry/documents/TestDirectory/", Connector.READ);
fconn.setWriteable(false);
fconn.close();
}
catch (Exception e){
}
finally {
try {
if (fconn != null) {
fconn.close();
fconn = null;
}
}
catch (Exception e) {
}
}