gpt4 book ai didi

java-me - j2me midp 2.0 中的 FileConnection 权限消息?

转载 作者:行者123 更新时间:2023-12-02 15:23:17 27 4
gpt4 key购买 nike

我使用的是midp 2.0。在这里,我使用 FileConnection 在移动内存上读写文件。我能够在手机上成功读取和写入文件。但是,当我尝试在移动设备上写入文件数据时,它会询问如下消息。

Application wants to read from the local file system

is it OK to read your files?

如果我按"is",则会再次显示

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*/

最佳答案

这不是与编码相关的问题。基本上这种类型的确认警报要求安全目的。因为您使用的是 JSR-75。

为此,您需要至少使用任何第三方签名(例如来自 Verisign 或 Thrawte 的签名)对您的应用程序进行签名,然后转到应用程序设置 - 权限 - 并将“访问用户数据”的权限设置为“仅询问一次”或“始终允许”(这些设置可能不适用于设备上未签名的应用程序。)

如果您在模拟器上遇到此问题,请转至首选项和 MIDP 选项卡,将应用程序域设置为“受信任”,并将权限设置为“始终允许”。欲了解更多信息,请参阅here...

签名网站是,

Thawte

Verisign

Java Verified

关于java-me - j2me midp 2.0 中的 FileConnection 权限消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4644067/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com