×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    FileConnection problems

    Hey guys

    I have googled around for tutorials of using FileConnections etc. But none of them seem to work and I have no idea why:

    This is the simple code i have:

    FileConnection connection = (FileConnection)Connector.open("file:///FooStats/");
    return String.valueOf(connection.exists());

    it is wrapped in a try catch block and returns the following:
    java.io.IOException: Opening a connection failed: -5

    It does not work on my Nokia N81 nor a Sony Ericsson K810i.

    and if I change it to: file:////FooStats/ it gives me this error:
    Opening a connection failed: -27

    Thanks for any feedback. Coz I assume the path I am using is incorrect, but I have no idea what it should be.

    Thanks for any help

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: FileConnection problems

    Another tutorial that I found does this:

    connection = (FileConnection)Connector.open("file:///"+
    rootFileSystem+"Foods/");

    but they do not specify what the rootFileSystem is.

  3. #3
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: FileConnection problems

    I suggest to work on dynamic paths rather than hardcoding them for this thes links might be helpful

    to know haow many roots i.e. c:, d:, etc are in devies

    listing folder nd files

    So what you have to do is fetch the root in ur device first then create path depending on that drive letter in your path you haven't mention any drive letter while real devices use drives also use /// correct form rather than //// incorrect form
    Regards,
    Saurabh

  4. #4
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: FileConnection problems

    Hi

    Thanks for the reply.

    Yea, I know about the FileSystemRegistry. That works fine and it outputs the following:

    Phone memory/
    C:/
    Memory card/
    E:/

    And thanks for the tip with the 3 ///. That works perfect with C: and rights out Data/ as the folder name.

    But if I try E:/ it says:

    SecurityException: Access Denied. Can a j2me app only write to C:/ or what? Or could it maybe only be one folder that is access denied which breaks the entire thing when looping through it?

    Thanks

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: FileConnection problems

    Ok, everything is now working. Thanks a lot for the help. It was just 1 folder while looping that gave access denied. As now I can read and write on E:/ with no problems.

    Thanks again

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: FileConnection problems

    Hi

    Just another question. Using the code on the link you sent me to loop through all the folders on E:/. The app asks for read permissions on every one. So I have to sit and say yes, yes, yes all the time .

    How do I get my app to only ask once for read and once for write?

    Thanks

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: FileConnection problems

    On some devices, you can switch the security settings for the application (in the application manager) from "ask always" to "ask first time". However, I think "ask first time" is not available for file system access to untrusted application on Series 60 3rd FP2 devices (like the N81). See here.

    To make your application "trusted" (and enable more security options), you need to sign it. This is a hideously complex area, and requires you to spend money! If you want to learn more about it, start here... and then read everything you can find!

    Graham.

  8. #8
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: FileConnection problems

    hmmmm. Ok, thanks for the info.

Similar Threads

  1. FileConnection not working on device
    By sandeepkumar03 in forum Mobile Java General
    Replies: 2
    Last Post: 2009-06-24, 05:51
  2. [ASK] FTP Client with FileConnection
    By calyp5o in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2008-07-30, 15:50
  3. Several problems with NMIT 4.1
    By jtalviva in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2006-03-10, 10:59
  4. Replies: 2
    Last Post: 2005-06-10, 19:31

Posting Permissions

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