×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    104

    FileConnection first steps

    Hello everyone,

    I just wrote my first test program using the file connection api.

    I have tested it on the emulator and it works fine.

    then i loaded it onto my E60 and reading files works just fine but when i try to create a folder the application just closes

    this is my function to create my folder
    Code:
        public void createFolder() {
            try {
                FileConnection filecon = (FileConnection) Connector.open("file:///C:/Data/test/");
                // Always check whether the file or directory exists.
                // Create the file if it doesn't exist.
                if (!filecon.exists()) {
                    System.out.println("makedir");
                    filecon.mkdir();
                }
                filecon.close();
            } catch (IOException ioe) {
                System.out.println(ioe.getMessage());
            }
        }
    filecon.mkdir();

    is causing the application to close

    is it that i cantcreate files/folders on the device at all?
    or can i only create files/folders in certain paths?

    this funktion asks for permission evertime but works fine:
    Code:
        private void getRoots() {
            Enumeration drives = FileSystemRegistry.listRoots();
            System.out.println("The valid roots found are: ");
            while (drives.hasMoreElements()) {
                root = (String) drives.nextElement();
                System.out.println("\t" + root);
            }
        }

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

    Re: FileConnection first steps

    application must have throw an exception before closing. i would suggest dsplay the exp.message in an alert instead of using system. out. println on device. this will let u know the exception. yes u r true, u r only allowed to create files and folders at certain location. try images folder in ur mobile. create a folder.
    Regards
    Nouman

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    104

    Re: FileConnection first steps

    nope no exception

    even when i try to catch it with an alert the application just closes on this line:

    FileConnection filecon = (FileConnection) Connector.open("file:///C:/Data/test/");


    I just tried with this:

    FileConnection filecon = (FileConnection) Connector.open(System.getProperty("fileconn.dir.private")+"test/", Connector.WRITE);

    but then the application will exit on this line:

    filecon.exists();

    no exeptions thrown:-(
    Last edited by Rozik; 2007-06-01 at 10:21.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    12

    Re: FileConnection first steps

    Try catching a Throwable instead of IOException, and then display the alert. Sometimes catching a specific exception will miss undeclared Exceptions and Errors.

    Display the exception in an alert.

Similar Threads

  1. FileConnection SecurityException Access Denied?
    By sbwoodside in forum Mobile Java General
    Replies: 8
    Last Post: 2008-07-23, 12:41
  2. Need help to find out the error in FileConnection!
    By katy2 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-04-02, 08:05
  3. (FileConnection) Share apps between 6600 and 6630
    By matteopiccioni in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2006-06-21, 21:59
  4. fileconnection api
    By beenicravi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2005-08-08, 14:51
  5. Java FileConnection Optional Package 1.0 (JSR 75)
    By thecrowi in forum Mobile Java General
    Replies: 0
    Last Post: 2004-09-24, 08:29

Posting Permissions

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