Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Dec 2011

    [moved] Problema with FileConnection

    I am using the FileConnection API with J2ME to write to a file on your phone
    NOKIA C5-03. With this phone works perfectly.

    Now I'm having problem with the Nokia 500, mobile phone will replace the C5-03.

    The application does not create the file.

    Below the code I'm using.

     private static String PATH_FILE_MEMORY_CARD = "file:///Memory card/Others/Araujo/";  
     public static void saveFile(String batLvl, String path) {  
             try {  
                 try {  
                     filedir = (FileConnection) Connector.open(PATH_FILE_MEMORY_CARD, Connector.READ_WRITE);  
                 } catch (Exception e) {  
                      FileConnectionUtil.logString("7.(FileConnectionUtil) " + e.getMessage());  
                 file = (FileConnection) Connector.open(PATH_FILE_MEMORY_CARD + path , Connector.READ_WRITE);  
                 try {  
                 } catch (IOException io) {  
                     try {  
                     } catch (Exception e) {  
                         FileConnectionUtil.logString("8.(FileConnectionUtil) " + e.getMessage());  
                 if (file.canWrite()) {  
                     OutputStream out = file.openDataOutputStream();  
                     out.write(batLvl.getBytes(), 0, batLvl.getBytes().length);  
             } catch (IOException ex) {  
                     FileConnectionUtil.logString("9.(FileConnectionUtil) " + ex.getMessage());  

    Does anyone know how to help me find out what may be happening?
    Do you have any way to plug the phone into the computer and debug the application in any IDE, like Eclipse, Netbeans ..?

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007

    Re: [moved] Problema with FileConnection

    Hello andersoncarvalho,

    based on hands-on testing, I think it is due to the virtual part of the path i.e. 'Memory Card'. I used the memory card value as returned by System.getProperty("fileconn.dir.memorycard") instead of file:///Memory card/ and with that creating the file worked just fine.

    For more information, you might want to check these resources available on Java Developer's Library online:

    Java Developer's Library > Implementation notes > (JSR-75) FileConnection API (Optional Package) > Runtime environment notes > System properties

    Java Developer's Library > Developer's guides > Data handling > File access > FileConnection API > Using the FileConnection API > Accessing files and directories

    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

Similar Threads

  1. [moved] FileConnection API
    By Essam-ag in forum Mobile Java General
    Replies: 4
    Last Post: 2008-09-05, 18:20
  2. problema with CAknProgressDialog
    By silviuccia in forum Symbian
    Replies: 3
    Last Post: 2006-12-06, 12:39

Posting Permissions

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