×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    How to create a file in resource folder J2ME?

    Hi to All,

    I have to create a text file in resource folder in J2ME and write data in it.
    Is that possible?
    Regards,
    Juned Ahmed

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to create a file in resource folder J2ME?

    Do you mean that you want to create a text file that will become part of your application (that will not be changed), or do you want your application to create the text file on the device?

    For creating static data files for your application, see your IDE's documentation for "adding resource files".

    For storing data on the device, there are two techniques: see "persistent data" in the Forum wiki.

    Graham.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    Re: How to create a file in resource folder J2ME?

    Thanks, but I know how to write data in storage device and I was stuck in creating a file in resource folder. But I used record sotre to save data. I thought we cant create a file in resource folder. Is this write?
    Regards,
    Juned Ahmed

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to create a file in resource folder J2ME?

    For storeing data as a file on the device internal memory or memory card, you need device to suuport JSR-75 FCA API's and signing of midlet might also be needed.

    Ref to SUN WTK examples - PDAPDemo.

    thanks,
    ~Amitabh

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    Re: How to create a file in resource folder J2ME?

    Thanks.....
    Regards,
    Juned Ahmed

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    94

    How to write into a text file in J2ME?

    Hi to All,

    This is Urgent.I have to create a text file in drive and write/delete data into it.
    when I am trying to write in a already created file. It goes stuck in connection line.

    Here's my code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    import javax.microedition.io.*;

    public class FileConnection extends MIDlet implements CommandListener {
    private Command exit, start;
    private Display display;
    private Form form;
    public FileConnection ()
    {
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    start = new Command("Start", Command.EXIT, 1);
    form = new Form("Write To File");
    form.addCommand(exit);
    form.addCommand(start);
    form.setCommandListener(this);
    }
    public void startApp() throws MIDletStateChangeException
    {
    display.setCurrent(form);
    }
    public void pauseApp()
    {
    }
    public void destroyApp(boolean unconditional)
    {
    }
    public void commandAction(Command command, Displayable displayable)
    {
    if (command == exit)
    {
    destroyApp(false);
    notifyDestroyed();
    }
    else if (command == start)
    {
    try
    {

    OutputConnection connection = (OutputConnection) Connector.open("file:///c:/myfile.txt", Connector.WRITE );
    OutputStream out = connection.openOutputStream();
    PrintStream output = new PrintStream( out );
    output.println( "This is a test." );
    out.close();
    connection.close();

    }

    catch(Exception e)
    {
    System.out.println("file connection:="+e);
    }
    }
    }
    }

    Please advice.
    Last edited by junedahmed; 2010-04-21 at 09:50. Reason: found new way

Similar Threads

  1. Can i create jad file from j2me Code
    By chaoraksa in forum Mobile Java General
    Replies: 3
    Last Post: 2009-10-07, 09:38
  2. [split] mbm build error
    By mando222 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2009-03-29, 12:32
  3. Error : Cannot find file : for DUMMIES
    By PACALA_BA in forum Symbian
    Replies: 7
    Last Post: 2008-07-06, 13:18
  4. Problem with pyobfuscate
    By JOM in forum Symbian
    Replies: 3
    Last Post: 2008-06-20, 22:47
  5. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53

Posting Permissions

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