存储文本字段中的值

Store the values from a textField

如何存储在表单的文本字段中输入的值并将这些输入的值显示到另一个表单?我正在使用 java-me。我正在尝试使用 dbhelper,但我无法理解它。一段代码会有所帮助。我应该怎么办?任何帮助或正面评价将不胜感激。

这是我的代码:

public class Song extends Form implements CommandListener {
    private Display display;
    private List list;
    private final Command logout;
    private Command back;
    private final TextField songname;
    private TextField band;
    private final MIDlet midlet;
    private Command add;
    private Form form;
    private DbHelper dbhelper1;

    public Song(MIDlet midlet) {
        super("My Playlist");

        songname = new TextField("Song name: ", null, 20, TextField.ANY);
        band = new TextField("Singer/Band Name: ", null, 20, TextField.ANY);
        form = new Form("New form");
        logout = new Command("Logout", Command.OK, 0);
        add = new Command("Add", Command.OK, 0);
        back = new Command("Back", Command.BACK, 0);
        this.append(songname);
        this.append(band);
        this.addCommand(logout);
        this.addCommand(add);
        this.addCommand(back);
        this.setCommandListener(this);
        this.midlet = midlet;
    }

    public void startApp() {
        this.append("This is MainForm");
        display.setCurrent(this);
    }

    public void showInput() {
        String w = "by";
        String n = songname.getString();
        String c = band.getString();
        Form form = new Form("Input Value");
        this.append(n);
        this.append(w);
        this.append(c);
        System.out.print("\n");
        display.setCurrent(form);
    }

    public void commandAction(Command c, Displayable d) {

        if (c == logout) {
            Display.getDisplay(midlet).setCurrent(new LoginForm(midlet));
        }
        if (c == add) {
            showInput();
        }
        if (c == back) {
            Display.getDisplay(midlet).setCurrent(new Playlist(midlet));
        }
    }
}

您必须执行获取 TextField 表单并将其更改为新表单的功能。 我不知道你的表格是什么,但你可以轻松地将其更改为字符串。 像这样:

public Form ChangeForm(TextField s) {

    String str = s.getText() // get string from textfield
    // Setting new form..
    // return form
}