Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2009

    FileConnetion API Reading and Writing Best Practices

    Hi All,

    I have file in my project resources folder (Netbeans)that I need to read in the MIDLet. I am going wrong while trying to read this file, URI is not correct. This file is included in the jar file in the main library.
    I have Read through all the articles on FileConnection API. I have coupe of questions.
    File Connection API Sun

    FileConnection fc=(FileConnection)Connector.open("file:////testDB.xml", Connector.READ);

    From Sun developer API
    CFCard/ FileConnection fc = (FileConnection) Connector.open("file:///CFCard/");
    SDCard/ FileConnection fc = (FileConnection) Connector.open("file:///SDCard/");
    MemoryStick/FileConnection fc = (FileConnection) Connector.open("file:///MemoryStick/");
    C:/FileConnection fc = (FileConnection) Connector.open("file:///C:/");
    /FileConnection fc = (FileConnection) Connector.open("file:////");

    1) When your installation jar is moved to the device where the files in resources folder get stored?
    2) do we have system property "fileconn.dir.root" similar to the one fileconn.dir.photos"
    3) Whats the best way of not hard coding the file paths when reading and writing files.
    4) now if i write file that mobile user has to use it in which path that should be written. How to access that directory

    Whats the Best Practices in terms of avoiding hardcoding of file access paths, to have wide compatibility over mobile devices.
    Any help will be appreciated


  2. #2
    Regular Contributor
    Join Date
    Jan 2008

    Re: FileConnetion API Reading and Writing Best Practices

    first of all, if your files are into the resource folder, you can access them by using "this.getClass().getResourceAsStream("/fileName.txt"), instead of using FileConnection.

    1. They are "into" your MIDlet. You can have access to them by using getResouceAsStream("/fileName.txt").
    2. You can use "fileconn.dir.private" in Nokia devices.
    3. It is a hard question. Search for Forum Nokia articles. They can give you some clues.
    4. You can create a folder and the file into the "fileconn.dir.private" folder.

  3. #3
    Registered User
    Join Date
    Nov 2009

    Re: FileConnetion API Reading and Writing Best Practices

    thanks thiagobrunoms, i came across resourcestream but overlooked that option.
    That really worked and avoids security permissions issues as well
    Thanks for clearing other questions as well..

    Have a good day


Similar Threads

  1. exe and application reading and writing database
    By raj8nokiaforum in forum Symbian
    Replies: 3
    Last Post: 2009-10-06, 10:42
  2. Reading and writing to the Secure Element (Nokia 6131)
    By wobbly101 in forum Near Field Communication
    Replies: 0
    Last Post: 2007-11-09, 13:43
  3. reading and writing buffer contents
    By hm36 in forum Symbian
    Replies: 0
    Last Post: 2007-06-29, 14:15
  4. File reading & writing help, wav file redaing help
    By shubhamlahoti in forum Mobile Java General
    Replies: 6
    Last Post: 2007-06-27, 09:07
  5. reading from a file and writing to another file
    By ibraheemJazba in forum Symbian
    Replies: 3
    Last Post: 2007-03-08, 11:50

Posting Permissions

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