×

Discussion Board

Results 1 to 10 of 10

Thread: Access denied

  1. #1
    Regular Contributor
    Join Date
    Jun 2006
    Posts
    50

    Access denied

    Code:
     public void showFile(String fileName) {
             try {
                 String strPath = "file:///C:/";
                 FileConnection fc = (FileConnection)Connector.open(strPath  +fileName, Connector.READ_WRITE);
                 if(!fc.exists()) {
                     Alert alertE = new Alert("Info:", "File does not exist", null, AlertType.INFO);
                     Display.getDisplay(this).setCurrent(alertE);
                     throw new IOException("File does not exist");
                 } else{
                     Alert alertE = new Alert("Info:", "File does exist", null, AlertType.INFO);
                     Display.getDisplay(this).setCurrent(alertE);
                 }
                 
                 //fc.setReadable(true);
                 InputStream is = fc.openInputStream();
                 byte b[] = new byte[1024];
                 int length = is.read(b, 0, 1024);
                 System.out.println("Content of "+ fileName + ": ");
                 System.out.println(new String(b, 0, length));
                 Alert alertM = new Alert("Info:", new String(b, 0, length), null, AlertType.INFO);
                 Display.getDisplay(this).setCurrent(alertM);
                 
             } catch (Exception e) {
                 System.out.println(e.getMessage());
                 Alert alert = new Alert("Info:", e.getMessage(), null, AlertType.INFO);
                 Display.getDisplay(this).setCurrent(alert);
                 //Display.getDisplay(this).vibrate(5000);
             }

    I have this function to see a file, but give me an error saying: "Access denied". Even in my 6230i emulator give me the same error. I have the file that want to open on [mypath]:\Nokia_S40_DP20_SDK_6230i\bin\Storage\6230100\C\, but nothing happens, only the error.


    What I have to do?

  2. #2
    Regular Contributor
    Join Date
    Nov 2004
    Posts
    105

    Re: Access denied

    String strPath = "file:///C:/";
    FileConnection fc = (FileConnection)Connector.open(strPath +fileName, Connector.READ_WRITE);

    There's your problem.
    J2ME can't write to C:/ sometimes

  3. #3
    Regular Contributor
    Join Date
    Jun 2006
    Posts
    50

    Re: Access denied

    But I only want to read some file at some location defined.

    Don't forget that I'm testing in emulator of 6230i.


    What I have to do more?!?!?!?!?!?


    Thanks

  4. #4
    Regular Contributor
    Join Date
    Nov 2004
    Posts
    105

    Re: Access denied

    Test it on your actual phone for starters.

    In my experience , I got the same error working with a 6680. It was fine once I used E:\ (SD CARD) instead of C:\ (Phone Memory)

    I may be wrong - but that's what happened to me

  5. #5
    Regular Contributor
    Join Date
    Jun 2006
    Posts
    50

    Re: Access denied

    Well...

    In emulator using E:/ the error ocurrs too.

    In a real 6230i it's a kind of impossible, because I do not have it. Only have 6230 that not support Fileconnection API.



    If anyone can help me, I apreciate.

    thanks

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Access denied

    I think the file name you are using is the problem (you should not try to access hardcoded files on your development computer anyway). There are a set of System Property strings, which get you the directories to certain files (see http://www.forum.nokia.com/info/sw.n..._2_en.zip.html)

    Also check this File Connection document which lists these strings(http://www.forum.nokia.com/info/sw.n..._v1_1.zip.html)

    Hartti

  7. #7
    Regular Contributor
    Join Date
    Jun 2006
    Posts
    50

    Re: Access denied

    So hartti...

    1 - You're saying that I can't try my read file application on 6230i emulator?!?!?!?

    2- I've already try whith DefaultColorPhone from J2ME Wireless Toolkit 2.2 and worked. Why???


    If first question is correct I'm screwed because I do not have the real phone. How can I try this out!?!?!?!?!?



    Thanks guys for the help

  8. #8
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Access denied

    I think I misunderstood a little what files you are trying to access. My bad.

    1. you can use FileConnection API on emulator.
    2. Not all directories are available for midlets on phones/emulators. The available directories vary.

    The emulator emulates the phone as closely as possible. If you want to read files in your midlet, you should query the correct and available paths from the system both on emulator and on a real device. Those are listed on the documents I pointed out before.

    Hartti

    BTW. What is the complete file name of the file you are trying to access? (Meaning what is the file name you passing to the open() method?)

  9. #9
    Registered User
    Join Date
    Feb 2009
    Posts
    6

    Re: Access denied

    I have the same problem and no body answer here in Nokia Forums.....

  10. #10
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105
    nissimzo, do you really need JSR-75 as you use fixed paths? If you want to read a static file, you can include it within your JAR. If you want to save values for later use, you should check RecordStore API. Did that help?

Similar Threads

  1. FileConnection SecurityException Access Denied?
    By sbwoodside in forum Mobile Java General
    Replies: 8
    Last Post: 2008-07-23, 12:41
  2. Nokia 6101 Locked 2 TMobile Midlet can't access internet...
    By Jason Glass in forum Mobile Java Networking & Messaging & Security
    Replies: 45
    Last Post: 2007-11-14, 02:19
  3. Access denied to inbox via JSR-175 on 6630.
    By n.lindberg in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2006-02-14, 15:46
  4. iConnection.Start(prefs) access denied
    By rakesh.jaiswal in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2005-04-04, 10:59
  5. Access Denied Error and a DBMS 2 Panic
    By kiranpuranik in forum Symbian
    Replies: 0
    Last Post: 2004-05-13, 11:18

Posting Permissions

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