I am using midp 2.0. Here I use FileConnection to read and write files in mobile memory. I can read and write files well on mobile phones. But while I try to write data on a mobile device, it asks for a message, as shown below.
Application wants to read from the local file system
is it OK to read your files?
if I click yes then it will be displayed again
Application wants to write to the local file system
is it OK to update your files?
This message is displayed continuously for approximately 10 times.
Is there a way to prevent this from happening more than once?
I also included my fileWrite method for your reference:
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;
}
source
share