3

I developed application in J2ME in which I have to make a file connection, but when I run this application it gives an exception:

Application not authorized to access the restricted API

I signed the build using the signing server and it works fine in other device except this device. Below is my code for the same.

Below is my code for file connection. It first constructs the filepath

 String dir = "file://" + Util.get_root_dirFrom() + "m/demo.res"; // Filepath for the application
 Log.p("Inside the loadString method......dir");
 FileConnection fc = null;
 InputStream fis = null;
 try {
   fc = (FileConnection) Connector.open(dir, Connector.READ);// Make a file connection
   fis = fc.openInputStream();
 }catch(Exception ex){
   Log.p("Exception...."+ex.getMessage());
 }

Util.get_root_dirFrom() methods return the dir for memory card in this device.

How to resolve this issue?

gnat
  • 6,213
  • 108
  • 53
  • 73
Megha
  • 1,581
  • 2
  • 18
  • 33

2 Answers2

1

I don't think it's the code's problem.

Cell phones has this security against some J2ME functions.
You probably just have to set the Application's permission settings so that it can be able to read/write on the file system.

Exactly how you have to do that depends from phone to phone, but you'll probably find it fast.

SmRndGuy
  • 1,719
  • 5
  • 30
  • 49
  • Hi,Thanks for your replay i check the phone security but it does not contain any special permission into that because my application work on this device before 15 days and now it not works i also restore factory setting of the phone but it not help. – Megha Apr 30 '12 at 13:32
0

i think SmRndGuy answer is correct.Better you choose another folder for file io operations

SIVAKUMAR.J
  • 4,258
  • 9
  • 45
  • 80
  • Ya that's true but some day's back on this Myphone QT7 Duo it work fine with no exception – Megha May 01 '12 at 11:43