问题
I am using midp 2.0. Here, I am using FileConnection for read and write files on mobile memory. I am able to read and write files on mobiles successfully. But while I am trying to write file data on mobile, it asking message like below.
Application wants to read from the local file system
is it OK to read your files?
if I press yes, then it again shows
Application wants to write to the local file system
is it OK to update your files?
These message are continuously showing approximately 10 times.
Is there any way to prevent this repeating this more than one time?
I have included my fileWrite method for your reference also:
public String fileWrite(String root)
{
FileConnection fc = null;
String fName = "test.txt";
DataOutputStream dos=null;
try
{
fc = (FileConnection) Connector.open(root + fName, Connector.READ_WRITE);
if(!fc.exists())
{
fc.create();
}
else
{
System.out.println("File Exists part");
fc.delete();
fc.create();
}
dos = fc.openDataOutputStream();
dos.write("f".getBytes());
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
fc.close();
dos.close();
}
catch (IOException e) { }
}
return "Saved in "+root+fName;
//return "NULL";
}//filewrite ends here*/
回答1:
This is not coding related issue. Basically this type of confirm alert asking for security purpose. Because you are using JSR-75.
In this purpose, You need to sign your application with atleast any 3rd party signature like one from Verisign or Thrawte and then go to the application settings - permissions - and set permission for "Access User Data" as "Ask only Once" or "Allow Always" (these settings might not be available for your unsiged app on the device.)
If you facing this Issue on the emulator, go to preferences and MIDP tab, set the application domain to Trusted and set permission as "Allow Always". For more info, see here...
Signing sites are,
Thawte
Verisign
Java Verified
回答2:
If you go to 3rd party trusted certificate means its minimum cost is RS.10000 per year. For deploying your application in client (final stage). It will worth.
But for testing, validating input, developing stage the cost is high. So check if your mobile has support for self signed certificate. If it supports self signed certificate, then process with self signed certificate.
But keep in mind self signed certificate is only for testing / development purpose. For delivering the project to client you should go to trusted party certificates.
来源:https://stackoverflow.com/questions/4644067/fileconnection-permission-messages-in-j2me-midp-2-0