j2me midp 2.0中的FileConnection权限消息? [英] FileConnection permission messages in j2me midp 2.0?

查看:60
本文介绍了j2me midp 2.0中的FileConnection权限消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

这些消息连续显示大约10次.

These message are continuously showing approximately 10 times.

有什么办法可以防止这种情况重复多次?

Is there any way to prevent this repeating this more than one time?

我还提供了我的fileWrite方法供您参考:

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

推荐答案

这不是与编码相关的问题.基本上,这种类型的确认警报是出于安全目的.因为您正在使用JSR-75.

This is not coding related issue. Basically this type of confirm alert asking for security purpose. Because you are using JSR-75.

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

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.)

如果在模拟器上遇到此问题,请转到首选项"和"MIDP"选项卡,将应用程序域设置为受信任",并将权限设置为允许始终".有关更多信息,请参见此处...

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...

签名站点是

Thawte

Verisign

已通过Java验证

这篇关于j2me midp 2.0中的FileConnection权限消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆