How to give the security permissions to delete file from my sdcard in blackberry?
How to give the permissions to delete a file from SDCARD. Following code is working on simulator but in the phone, It's not working. 开发者_如何学运维How to solve my problem?
FileConnection fileConnection1=(FileConnection)Connector.open("file path");
fileConnection1.setWritable(true);
fileConnection1.delete();
You can request permissions from the person running your application but you may not forcefully set them so you need to gracefully handle your request being rejected.
The API involved is ApplicationPermissionsManager
I suggest you look at and possibly use this sample code (depending on which OS versions you are supporting) because there are a few quirks also explained at this url.
The exact permission you are looking for might be: ApplicationPermissions.PERMISSION_FILE_API
But I suggest you check the versions you are developing against for deprecation as several permissions have been retired or changed names over the years.
精彩评论