【发布时间】:2011-01-10 05:54:52
【问题描述】:
我正在使用 midp 2.0。在这里,我使用 FileConnection 在移动内存上读写文件。我能够成功地在手机上读写文件。但是当我尝试在移动设备上写入文件数据时,它会询问如下消息。
Application wants to read from the local file system
is it OK to read your files?
如果我按是,那么它会再次显示
Application wants to write to the local file system
is it OK to update your files?
这些消息连续显示大约 10 次。
有什么办法可以防止这种情况重复多次吗?
我还包含了我的 fileWrite 方法供您参考:
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*/
【问题讨论】: