×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    10

    how to save file & how to save settings?

    hi there!

    I'm working on an application, that will handle some XML files.
    Ich want to store the XML files on the device. They should be downloaded via HTTP.
    At the moment I'm using a "online" version:

    Code:
    HttpConnection httpConnection = (HttpConnection) Connector.open(URL);
    KXmlParser parser = new KXmlParser();		
    parser.setInput(new InputStreamReader(httpConnection.openInputStream()));
    I could take the new InputStreamReader(httpConnection.openInputStream()); and save this...

    My Questions are:
    Is there a specific "Home" directory for midlets on the mobile phones, where i can store the xml files?
    Is there a API for handling files/directories?

    i didn't find a hind in the internet...

    for reading a file i'm currently using:
    Code:
            	 InputStream is = getClass().getResourceAsStream("test.txt");
            	    try 
            	    {
            	      StringBuffer sb = new StringBuffer();
            	      int chr;
            	      // Read until the end of the stream      
            	      while ((chr = is.read()) != -1)
            	          sb.append((char) chr);
    
            	      String str = sb.toString();
            	      
            	      System.out.println(str);
            	    }
            	    catch (Exception e)
            	    {         
            	      System.out.println("Unable to create stream");
            	    }
    But its only working, when i'm packing the test.txt in my project file.

    I also want to save some Settings of my Program (some choiceGroups etc).
    Many Games have to use this, right? So maybe there is a simple solution...


    it would be very cool, if you have some hints for me.
    Even if its nothing regarding my questions, it could make sense. i'm rather a newbie

    thanks,
    Martin
    Last edited by MGvision; 2007-06-13 at 10:18. Reason: adding a question..

  2. #2
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Re: how to save file & how to save settings?

    Hi Martin,

    You may want to read up on RMS, and alternatively JSR75 (allows a MIDlet access to the file system).

    See this tutorial
    http://developers.sun.com/techtopics...icles/persist/

    So with the RMS, there is not a concept of files as such, but record stores and records, and you pretty much have to manage it yourself.

    We have built various gile system management functions around record stores to make it simple and abstract for future applications.

    Regards

    Ben
    www.myiota.co.uk

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    10

    Re: how to save file & how to save settings?

    Thank you very much!

    I'll use the RMS for the Settings and the JSR75 to store the XML files.


    Do you know, if there is a special directory for storing this files?
    I'm thinking of something like a Unix "/home/user/.myxml" directory


    thx,
    Martin

Similar Threads

  1. File corrupted - with signed sis
    By annehj in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2007-12-10, 13:44
  2. generate, save and load MIDI file
    By hp3 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2006-09-20, 23:17
  3. Save a file from internet
    By Amilael in forum Symbian
    Replies: 2
    Last Post: 2006-09-20, 06:43
  4. File Save!
    By georgica1979 in forum Symbian User Interface
    Replies: 7
    Last Post: 2003-04-11, 20:13

Posting Permissions

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