×

Discussion Board

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

    [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.


    Code:
     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);  
       
                     if(!filedir.exists())  
                     {  
                         filedir.mkdir();  
                         filedir.close();  
                     }  
                 } catch (Exception e) {  
                      FileConnectionUtil.logString("7.(FileConnectionUtil) " + e.getMessage());  
                 }  
                 file = (FileConnection) Connector.open(PATH_FILE_MEMORY_CARD + path , Connector.READ_WRITE);  
       
       
                 try {  
                     file.create();  
                 } catch (IOException io) {  
                     try {  
                         file.delete();  
                         file.create();  
                     } catch (Exception e) {  
                         FileConnectionUtil.logString("8.(FileConnectionUtil) " + e.getMessage());  
                     }  
                 }  
                 if (file.canWrite()) {  
                     OutputStream out = file.openDataOutputStream();  
                     out.write(batLvl.getBytes(), 0, batLvl.getBytes().length);  
                     out.close();  
                     file.close();  
                 }  
             } 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
    Posts
    1,595

    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

    Regards,
    r2j7
    [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. problema con el DRM
    By evonbb in forum Foro en Español (Spanish Forum)
    Replies: 0
    Last Post: 2010-06-24, 09:12
  2. [moved] FileConnection API
    By Essam-ag in forum Mobile Java General
    Replies: 4
    Last Post: 2008-09-05, 18:20
  3. el problema configurando
    By luiscunza in forum Foro en Español (Spanish Forum)
    Replies: 0
    Last Post: 2008-01-25, 15:56
  4. problema con formularios
    By haydn in forum Foro en Español (Spanish Forum)
    Replies: 0
    Last Post: 2007-07-21, 17:08
  5. problema with CAknProgressDialog
    By silviuccia in forum Symbian C++
    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
  •