10-09-2011 11:07 AM - edited 10-09-2011 11:27 AM
public class CreateFileApp extends Application
{ public static void main(String[] args)
{ CreateFileApp app = new CreateFileApp();
app.setAcceptEvents(false);
try {
FileConnection fc = (FileConnection)Connector.open("file:///store/home
if (!fc.exists()) // CONTROLLED ACCESS EXCEPTION
{
fc.mkdir();
}
fc.close();
} catch (IOException ioe)
{ System.out.println(ioe.getMessage() );
}
}
I am trying to run this sample application found in BB Document;
When I tried debugging the application it is throwing controlled access exception at the above hightd line.
In simulator it is popping up a error message Applciation Terminated: File system has been denied the "Files " permission.
Any help is welcomed. ![]()
A Y
Solved! Go to Solution.
10-09-2011 05:22 PM - edited 10-09-2011 05:23 PM
Hi avi_yach,
In the simulator settings, there is an check-box to use the computer as the file system. you should check this option.
In your device, try changing the application permissions.
E.
10-09-2011 06:40 PM
10-10-2011 12:01 AM
When you get controlAccessException then It is better to clean and restart/only restart the simulator. You should not get this exception in device because you are again and again debugging in simlator. This is not the case in device. That's why.
==================================================
Feel Free to click THUMB(LIKE) symbol.
10-10-2011 01:05 AM
Hello maadani, thanks for your reply, I have enabled this option "using computer as file system". I will share the procedure which I followed, I created a folder called SDCard in my private directory and in simulator memory settings I matched the memory to SDCard on the H folder.
A Y
10-10-2011 01:11 AM
Hello CMY, thanks for your reply, can you suggest me how to change the simulator settings? In couple of posts they have suggested to disable simulator security settings. Is it possible?
A Y
10-10-2011 01:12 AM - edited 10-10-2011 01:14 AM
Thanks for your reply Alishaik, I tried this, but no luck ![]()
A Y
10-10-2011 02:23 AM - edited 10-10-2011 02:24 AM
Another couple of things that might help:
1. Try to create a directory under "file:///store/home/user/" and create your file in the new directory.
2. Try create your file with just the file name: "FileConnection)Connector.open(file_name.txt);"
3. Try using a parameter in the open function: "FileConnection)Connector.open(file_name.txt,Conn
E.
10-10-2011 03:15 AM
You are checking file exist or not. And if not exists then you are creating a Directory not a file.
try
{
FileConnection fc=(FileConnection)Connector.open(PATH);
if(fc.exists())
fc.truncate(0);
else
fc.create();//here you are creating a directory instead or file.
//Write what ever you want;
fc.close();
} =================================================
Feel Free to click THUMB(LIKE) button.
10-11-2011 05:44 AM - edited 10-11-2011 05:45 AM
@all : after long slogging I realised that application not having permission to access Files can be a reason for this error. This can be avoided by (BlackBerry 9550)settings>Application>menu>edit default permission>connections>allow
any other alternative is also welcomed ![]()