×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    26

    Nokia S40 Writing File

    I want to write an xml file to the mobile memory. i did the following:
    FileConnection fc = (FileConnection) Connector.open("file:///c:/Gallery/myFile.txt",Connector.READ_WRITE);
    if(!fc.exists())
    fc.create();

    but i getting the following error. java.lang.SecurityException Access denied.
    How can i solve that? Does anyone have an idea baout that?
    Thanks a lot....

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Nokia S40 Writing File

    Can you check if your MIDlet has any access to read/edit user data? On S60 phones go through Application Manager. On Series 40 phones you should see that in the Options menu when the MIDlet is selected.

    If only No Access is available, you are likely using a operator branded phone. (which operator and which phone, btw)

    Otherwise you might not have access rights to the file in question (however the directory looks ok, so this should not be the problem...but I might be mistaken here)

    Hartti

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    26

    Re: Nokia S40 Writing File

    I am using Nokia 6151 that supports JSR75. I checked the Application Access of the MIDlet, and i can choose for "Add and edit data" "Ask every time".
    I installed the Application PDADemo that comes with WTK25 and in the FileBrowser i can see only c:\ but also i can't access it it because i m getting java.lang.SecurityException Access Denied. So, i donno if i should sigh the application to let me to access to the c:\.
    Also i m using S40_SDK_3rd_Edition_Feature_Pack_1 and i m getting the same error
    Last edited by hooopoe; 2007-06-19 at 07:19.

  4. #4
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Nokia S40 Writing File

    try another folder keeping checking all the folder. there must be some folder which will not give security exception
    Regards
    Nouman

  5. #5
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: Nokia S40 Writing File

    From the FileConnection API Developers Guide:

    In addition, there is an extra layer of restrictions with respect to file access. Depending on the security
    domain the MIDlet has been assigned during installation, it will have access to a subset of the file system.
    This is designed to protect the user data and prevent damage to the operating system. In particular, MIDlets
    located in the trusted third-party and untrusted domains have access only to a set of designated public
    directories including those for images, videos, public files, and a private directory assigned to each MIDlet
    for its own usage. This is one reason why using virtual roots is recommended since access to the
    Images/ root may be allowed but doing traversal from c:/ to c:/data/Images/ may not be allowed,
    because c: could not be accessible by a MIDlet.
    Several file-related operations check if the appropriate security permissions have been acquired, but you
    should be careful in particular when the Connector.open() method is called. After a
    FileConnection has been created and the appropriate permission has been granted, it could be assumed
    that the permissions will hold for other operations requiring the same permission. For instance, once a
    FileConnection has been created for writing, invoking delete should also have been authorized. If
    the FileConnection has been created with a read permission and the delete() method is called, the
    write permission will be needed and the user will be prompted if necessary.
    The setFileConnection() method will also check for permissions to those files, depending on which
    mode the original FileConnection was created. This is quite logical since setFileConnection
    changes the current connection to point to a different file or directo

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    26

    Re: Nokia S40 Writing File

    First of all i m checking the root of the mobile i am getting only "C:/" because i don' t have a memory card. So, i tried in the application with all location of with the application access for Data Access for Add and edit data is "Ask every time" in "C:/Gallery" and i m still having the same problem java.lang.SecurityException. So. did someone has succeed to do that ... plus, it s related to application sgning. I search all the forums, and i didn't not find any solution, and i tried all the possibility...Any Idea.....

  7. #7
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: Nokia S40 Writing File

    Have you read the document fragment below?

    This is one reason why using virtual roots is recommended since access to the
    Images/ root may be allowed but doing traversal from c:/ to c:/data/Images/ may not be allowed,
    because c: could not be accessible by a MIDlet.
    You have to check the FileConnection API Developers Guide document to find out which virtual roots and filesystem areas your midlet will be able to access.

    Daniel

Similar Threads

  1. Series 60Series 60 MIDP Concept SDK Beta 0.2 Linux bug?
    By kauppi in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2003-04-07, 09:05
  2. Http connection problem in 6310i
    By teahola in forum Mobile Java General
    Replies: 1
    Last Post: 2002-10-03, 18:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×