如何在BlackBerry中更改文件/目录权限?

时间:2012-08-29 08:57:14

标签: blackberry

是否可以将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) {
}
}

0 个答案:

没有答案