Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
ankurnema12
Posts: 18
Registered: ‎10-23-2012
My Device: 9500

How To save Data or Text From Edit Filed To somewhere In memery

hi..i want to save some data from edit field to some whare in memory on a click of Save Button but it is not working...any suggetion ..

 

 

 

public FileAppMainScreen() 

{

// TODO Auto-generated constructor stub

editfield=new EditField("Enter Text:","");

add(editfield);

 

try

{

FileConnection fconn=(FileConnection)Connector.open(filepath,Connector.READ_WRITE);

if(!fconn.exists())

{

fconn.create();

}

OutputStream os=fconn.openOutputStream();

os.write(editfield.getText().getBytes());

os.write("testcontentWelcome".getBytes());

//os.close();

 

}

 

catch(IOException ioe)

{

 

}

 

}

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How To save Data or Text From Edit Filed To somewhere In memery

first: don't do I/O on the main thread.
see
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

your code is also called on the constructor, the editfield cannot have any text there.
better add a button or overwrite the save/onSave methods of mainscreen.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How To save Data or Text From Edit Filed To somewhere In memery