RecordStore JavaME

Hi,
I am new to JAVAME. I am trying to develop a application in which i need to remember a value for the next time the application starts. for example: before closing the application user types the last value in a textfield as 25. Next time when i open my application i should be able to remember this value 25. I know i have to user RecordStore, but i am not able to access this value.
I can store the value, i can retrieve the value......but can anyone tell me how i can save the value forever.
Thanks in advance.

There is no "toolbar" folder in Java ME SDK installation dir anymore. All developer tools are moved to Netbeans plugins.
Remember, that Java ME SDK consists of two parts: emulator and developer tools.
In the given use case only emulator and other command line tools are accessible (see "bin" folder). You can run samples or your Java ME applications via command line interface.
To develop, debug and profile your applications you have to install Netbeans (6.9.1 or later, latest 7.0.1 is recommended) and Java ME SDK Tools on top of it.
You can do it either via installer (Netbeans have to be installed before you start Java ME SDK installation) or later from Netbeans Plugins manager (see Developer Guide in "docs" folder for details).
So, nothing wrong with installation in your case.
The only problem is the broken shortcut for documentation in Start menu. We will fix it soon.
Edited by: Alexander Burdukov on 28.11.2011 8:32

Similar Messages

  • Mp3 and RecordStore Capable Emulator

    Currently I'm trying to develop an application that plays back mp3's. I am just wondering if there exists an emulator that can handle both, record sets and mp3 playback.
    WTK22 does a good job of handling recorcStores, but can not handle Mp3 playback.
    I did find a motorola emulator that handled mp3 playback, unfortunately it crashes as soon as I try and load information into the recordStore.
    If anyone knows of one, perhaps they could pass along the name, or even a link.
    Another question I do have about WTK22 is, is there any way of increasing the recordStore size, or is it stuck at 1MB . . . and what is the average size of a record store on a new phone these days?

    I wasn't sure what is RecordStore but apparently it is MIDP's way of persisting data.
    As it shows, I have little knowledge of JavaME, so I don't know if that's a problem with the emulator or the usage of RecordStore within JavaFX or something else.
    Now, perhaps you can use the [javafx.io.Storage|http://java.sun.com/javafx/1.2/docs/api/javafx.io/javafx.io.Storage.html] class for persisting data, it is designed to work both in JavaME and on desktop.
    It might offer less features than RecordStore, though.

  • Javafx and RecordStore problem

    Hi,
    I am creating a contact management mobile app with javafx, and I am using a RecordStore to store the data. As long as the emulator is open I have verified that the records are being added to the recordstore.
    However when I close the emulator and re start the app, the recordstore disappears, and it recreates the store (it says it has 0 records).
    I am using netbeans, and using the mobile profile.
    Any help will be highly appreciated...
    thanks in advance

    I wasn't sure what is RecordStore but apparently it is MIDP's way of persisting data.
    As it shows, I have little knowledge of JavaME, so I don't know if that's a problem with the emulator or the usage of RecordStore within JavaFX or something else.
    Now, perhaps you can use the [javafx.io.Storage|http://java.sun.com/javafx/1.2/docs/api/javafx.io/javafx.io.Storage.html] class for persisting data, it is designed to work both in JavaME and on desktop.
    It might offer less features than RecordStore, though.

  • JavaME SDK 3.0.5 not launching on Windows 7 64 bit OS using JDK 1.6.0_27 x8

    I installed JavaME SDK 3.0.5 on top of JavaME SDK 3.0 without uninstalling it at C:\Java_ME_platform_SDK_3.0.5 on Windows 7 64 bit OS using jdk1.6.0_27 x86.
    The installation went fine but i am not getting any shortcuts to launch JavaME SDK 3.0.5.
    No shortcut menu item for JavaME SDK launcher is available in start menu or no shortcut is available on desktop.
    Menu item group in start menu is created for JavaME SDK 3.0.5. It contains
    "Documentation" and "Uninstall" shortcuts only.
    When i clicked "Documentation" shortcut it complains for missing index.html file.
    I checked there is no toolbar folder present inside C:\Java_ME_platform_SDK_3.0.5.
    There used to be one for 3.0 at C:\Java_ME_platform_SDK_3.0\toolbar.
    I do have jdk1.6.0_27 x64 installed too. Does it creates any problem?
    Am i missing any installation or configuration step?
    I don't have netbeans installed on my computer.

    There is no "toolbar" folder in Java ME SDK installation dir anymore. All developer tools are moved to Netbeans plugins.
    Remember, that Java ME SDK consists of two parts: emulator and developer tools.
    In the given use case only emulator and other command line tools are accessible (see "bin" folder). You can run samples or your Java ME applications via command line interface.
    To develop, debug and profile your applications you have to install Netbeans (6.9.1 or later, latest 7.0.1 is recommended) and Java ME SDK Tools on top of it.
    You can do it either via installer (Netbeans have to be installed before you start Java ME SDK installation) or later from Netbeans Plugins manager (see Developer Guide in "docs" folder for details).
    So, nothing wrong with installation in your case.
    The only problem is the broken shortcut for documentation in Start menu. We will fix it soon.
    Edited by: Alexander Burdukov on 28.11.2011 8:32

  • Error when launching JavaME SDK 3.0 on Mac OSX

    I have installed JavaME SDK 3.0 for mac, and it seems present and correct in my applications folder. However, when i try to launch it, the splash screen gets to 'starting modules', then I'm presented with an error:
    A java.lang.reflect.InvocationTargetException exception has occurred.
         Click Show Details or see the messages.log file located in your /Users/William/Library/Application Support/javame-sdk/toolbar/3.0/var/log folder.
    Clicking on 'show details' reveals:
    java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
         at java.net.Socket.connect(Socket.java:525)
         at java.net.Socket.connect(Socket.java:475)
         at java.net.Socket.<init>(Socket.java:372)
         at java.net.Socket.<init>(Socket.java:186)
         at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
         at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
    Caused: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
         java.net.ConnectException: Connection refused
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
         at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
    Caused: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
         java.net.ConnectException: Connection refused]
         at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
         at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)
         at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
         at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
         at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
    Caused: java.io.IOException: Failed to retrieve RMIServer stub
         at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
         at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
         at com.sun.jme.toolkit.remoting.client.rmiimpl.ObjectServerConnectionImpl.connect(Unknown Source)
         at com.sun.jme.toolkit.remoting.client.rmiimpl.ObjectServerConnectionImpl.start(Unknown Source)
    Caused: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.jme.toolkit.bootstrap.Batch.invoke(Unknown Source)
         at com.sun.jme.toolkit.bootstrap.Batch.tryInvoke(Unknown Source)
         at com.sun.jme.toolkit.bootstrap.Batch.startObjectsImpl(Unknown Source)
         at com.sun.jme.toolkit.bootstrap.Batch.startObjects(Unknown Source)
         at org.netbeans.modules.javame.common.container.Module.start(Module.java:21)
         at org.netbeans.modules.javame.common.container.ContainerSupport.startModule(ContainerSupport.java:67)
         at org.netbeans.modules.javame.common.container.devicemanager.DevicemanagerHelper.getDeviceManagerConnection(DevicemanagerHelper.java:41)
         at org.netbeans.modules.javame.common.container.devicemanager.DevicemanagerHelper.ensureConnected(DevicemanagerHelper.java:48)
         at org.netbeans.modules.javame.common.container.devicemanager.DevicemanagerHelper.getDeviceManager(DevicemanagerHelper.java:84)
         at org.netbeans.modules.javame.profiler.Installer.getDevicesRegistrations(Installer.java:68)
         at org.netbeans.modules.javame.profiler.Installer.restored(Installer.java:39)
         at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:440)
         at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:361)
         at org.netbeans.ModuleManager.enable(ModuleManager.java:917)
         at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:289)
         at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:225)
         at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
         at org.netbeans.core.startup.Main.getModuleSystem(Main.java:168)
         at org.netbeans.core.startup.Main.start(Main.java:309)
         at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:111)
    [catch] at java.lang.Thread.run(Thread.java:637)
    Then, I get:
    A java.lang.NullPointerException exception has occurred.
         Click Show Details or see the messages.log file located in your /Users/William/Library/Application Support/javame-sdk/toolbar/3.0/var/log folder.
    Clicking on 'show details' reveals:
    java.lang.NullPointerException
         at org.netbeans.modules.javame.profiler.Installer.getDevicesRegistrations(Installer.java:70)
         at org.netbeans.modules.javame.profiler.Installer.restored(Installer.java:39)
         at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:440)
         at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:361)
         at org.netbeans.ModuleManager.enable(ModuleManager.java:917)
         at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:289)
         at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:225)
         at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
         at org.netbeans.core.startup.Main.getModuleSystem(Main.java:168)
         at org.netbeans.core.startup.Main.start(Main.java:309)
         at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:111)
    [catch] at java.lang.Thread.run(Thread.java:637)
    This continues for ages. The errors just keep on coming, and the mini IDE never launches. I do, however, see the device manger appear in the menubar for a couple of seconds, before it disappears and I get the next error. This repeats too.
    I have tried deleting the package from my applications folder, and the only support folder I can find: <username>/Library/Application Support/javame-sdk several times, and this has not helped.
    If i can provide any more useful info, please let me know - the log files mentioned in the error messages are so large I didn't think posting them would be helpful.
    I've been working on trying to solve this for several painful hours now, and any help you can offer would be gratefully received!

    Hi,
    I can see "Connection refused to host: localhost" message in your stack trace. Look at [http://blogs.sun.com/javamesdk/entry/first_aid_when_emulator_doesn|http://blogs.sun.com/javamesdk/entry/first_aid_when_emulator_doesn] and follow step 2, please. Hopefully it will help you.
    Best regards,
    Radko

  • About workin with RecordStore

    i have been workin on an application for Palm OS which deals with a lot of database.the application is workin fine and the data also seems to be consistent. however the problem started when i started to work with conduit for tha application. can someone tell me about a better way to manipulate the data stored by the recordstore using java conduit.
    thank u !

    kAWT is built on top of kJava and only works with kJava (I am not sure if anyone has ported it to MIDP). kAWT has nothing to do with databases, it is only for GUI management similar to J2SE AWT. So if you want to use kJava, you can use kAWT for your GUI, but you do not have to. Also, if you use kJava, regaurdless of kAWT, you can use the Palm database - the two are not mutually exclusive.
    Now for MIDP. kAWT, as far as I know, has not been ported to MIDP. MIDP is a replacement for kJava, and it also runs on Cell phones. MIDP is somewhat OK for Palm, but really does not take full advantage of the Palm and the palm native GUI components. On this forum, there is better support for support for MIDP than kJava.
    If you are going to write an application for the Palm and only for the Palm, and it must be in Java, AND you need to take advantage of sophisticated Palm OS features, consider downloading and using IBM's J9 compiler (VAME). It opens up the full Palm OS. However, writing Palm applications is not as easy as MIDP or kJava, and will take longer to learn. The support for J9 is through the IBM VAME newsgroup.
    If your application is simple, and you do not need to use the IR port, serial port, access other databases other than your own, or need to have tight control over the user interface, go with MIDP. Download Forte and the wireless toolkit from Sun and follow the install directions, and read the PDF documents in the /doc directory.
    Also, there are a large number of postings in this forum about using MIDP on Palms and MIDP with the wireless toolkit and Forte. There are also people form Sun who monitor and reply to problems in this forum when they pertain to MIDP. kJava does not have this level of support.
    Once you have picked your development tools, and if you have further problems, lets resolve them one at a time. Post the actual error message as a new topic and people in the forum will take it from there.
    Don

  • JavaME SDK 3.0 - A step back?

    Unfortunately this is a bit of a rant; but can someone state any reason why JavaME SDK 3.0 represents progress for the developer?
    It seems like my development environment just took a massive step backwards:
    - No UI configuration of the Platform: where did the nice preferences and utilities console go from WTK2.5?
    - The configuration functionality that remains seems to be limited to a handful of CLI apps in /bin/
    - My Thawte codesigning certificate is no longer recognised and the MIDlet refuses to run signed. No root certificates supplied with WTK3.0?
    - No Linux version.
    - After fixing a low memory issue that didn't occur in WTK2.5, my midlet now just fails with an 'InstantiationException'.
    I got the same results with the version included in Netbeans, and the latest standalone download from Sun.
    The [release page|http://java.sun.com/javame/downloads/sdk30.jsp] seems to state the reason for this release is to integrate different Java profiles under one SDK, but given how much functionality useful to J2ME developers has had to be torn out to make this work; I have to question whether it was worth it.
    The only other 'improvements' I can find to put a finger on is the inclusion of LWUIT - which is a great library - and BDJ stubs, however these were both very easily added by including a jar library in Netbeans anyway.
    Im generally a big fan of Java technologies but this seems to be a shambles of a release - yes developers are techies and to some degree can be expected to find their own way through issues, but this release breaks so much stuff, it just seems like Sun are expecting too much adaptation from us. Who here has the hours in the day? After much wasted time trying to resolve the issues with 3.0, I think I'll be going back to WTK2.5.
    Am I missing something?
    - Chris

    There is no "toolbar" folder in Java ME SDK installation dir anymore. All developer tools are moved to Netbeans plugins.
    Remember, that Java ME SDK consists of two parts: emulator and developer tools.
    In the given use case only emulator and other command line tools are accessible (see "bin" folder). You can run samples or your Java ME applications via command line interface.
    To develop, debug and profile your applications you have to install Netbeans (6.9.1 or later, latest 7.0.1 is recommended) and Java ME SDK Tools on top of it.
    You can do it either via installer (Netbeans have to be installed before you start Java ME SDK installation) or later from Netbeans Plugins manager (see Developer Guide in "docs" folder for details).
    So, nothing wrong with installation in your case.
    The only problem is the broken shortcut for documentation in Start menu. We will fix it soon.
    Edited by: Alexander Burdukov on 28.11.2011 8:32

  • Problem with RecordStore

    Hi all!
    I am building my first cell phone application and starting with J2ME. I "finished" my implementation but my app is not working properly. I dont know if the data is really being saved on the RecordStore or if the data is not being loaded correctly.
    I have 3 classes: Interface, Data and DAOdata. I will put the main parts:
    //My Interface
    public class Interface extends MIDlet implements CommandListener {
    //In this part I save some data to DataBase
    formPagto.setCommandListener (new CommandListener() {
                public void commandAction(Command c, Displayable s) {
                       if(c == salvaDesp){
                            String tmp = txtVal.getString();
                            float val = Float.parseFloat(tmp);
                            DAOdadata dados = new DAOdata();
                            dados.carregaDados(mesAtual());
                            dados.saveData(val, option, mesAtual());
                            novoDisplay(mList);
                       if(c == cBack)
                            novoDisplay(mListSec);
    //Here I load data from RecordStore. The problem, is that only 0 comes out
    mListMes.setCommandListener (new CommandListener() {
                public void commandAction(Command c, Displayable s) {
                  if(c == cResumo){
                       int x = mListMes.getSelectedIndex();
           DAOdata dados = new DAOdata();
           Data VR;
           VR = dados.loadData(x);
       //In this place all I get is 0%. And this is the problem. I should get different values.
           StringItem alim = new StringItem("Food: ", FloatToString(VR.getFood())+"%");
           StringItem vest = new StringItem("Health: ", FloatToString(VR.getHealth())+"%");
            fromVis.append(alim);
           fromVis.append(vest);
         Display.getDisplay(this).setCurrent(fromVis);
                  else if(c == cBack)
                       novoDisplay(mList);
    //My Data class. It´s a bean
    public class Data {
         private float salary;
         private float food,healty,cars, groceries;
    //Setters
    public void setSalary(float val){
              salary = val;
    //Getters
    public float getSalary(){
      return salary;
    //Finally my DAO class
    public class DAOdata {
    private RecordStore rs = null;
    Data dados;
    int month;
    public void loadDataBase(){
              try
                rs = RecordStore.openRecordStore(PERFIL_DB, true);
             catch (Exception  e){
                  System.out.println("Problem loadDataBase()");
    //Load data from RecordStore
    public Data loadData(int month){
              try{
               byte[] data = rs.getRecord(month);
               DataInputStream is = new DataInputStream(new ByteArrayInputStream(data));
               dados.setFood(is.readFloat()); 
               dados.setHealth(is.readFloat());       
               dados.setCars(is.readFloat());
               dados.setGroceries(is.readFloat());
               is.close( );
              }catch(Exception e){
                        //Never get exceptions in here
                   e.printStackTrace();
              return dados;
    //Saving data to RecordStore.
    public void saveData(float val, String tipo, int month){
              if(tipo.equals("Food")){dados.setFood(val);}
              else if(tipo.equals("Health")){dados.setHealth(val);}
              else if(tipo.equals("Cars")){dados.setCars(val);}
              else if(tipo.equals("Groceries")){dados.setGroceries(val);}
              try{
               ByteArrayOutputStream baos = new ByteArrayOutputStream( );
               DataOutputStream os = new DataOutputStream(baos);
               os.writeFloat(dados.getFood());
               os.writeFloat(dados.getHealth());
               os.writeFloat(dados.getCars());
               os.writeFloat(dados.getGroceries());
               os.flush();
               os.close( );
               byte[] data = baos.toByteArray( );
              rs.setRecord(mes, data, 0, data.length); //I use setRecord since the data is already initialized
               rs.closeRecordStore();
              }catch(Exception e){
                        //Never get exceptions in here
                   e.printStackTrace();
    //In this method I populate the RecordStore for the First time. I call this method 12 times, one per month
    public void initRecordStore(int month){
              dados.setFood(0);
              dados.setHealth(0);
              dados.setCars(0);
              dados.setGroceries(0);
              try{
                    ByteArrayOutputStream baos = new ByteArrayOutputStream( );
                    DataOutputStream os = new DataOutputStream(baos);
                    os.writeFloat(dados.getFood());
                    os.writeFloat(dados.getHealth());
                    os.writeFloat(dados.getCars());
                    os.writeFloat(dados.getGroceries());
                    os.close( );
                    byte[] data = baos.toByteArray( );
                   int id = rs.addRecord(data, 0, data.length);
                   rs.closeRecordStore();
                   }catch(Exception e){
                        //Never get exceptions in here
                        e.printStackTrace();
         }So, all that I get are 0% as a result. I dont get any exceptions when I load or save data. I dont know how to solve it. Any help will be welcome.
    Thank you all

    Hi, thanks for your answer.
    Actually I have seen a lot of examples before using the RecordStore.
    Maybe my problem is the way I am using the loadData() to retrieve information to another class. I am trying in a different way.
    Anyway, I will check more examples.
    Thank you =)

  • Chinese character in RecordStore

    Hi all,
    I am new to j2me. is it possible to key in Chinese character and store it in recordstore, and i can display the character back when i view the record?
    i have go through many examples of j2me encoding. but i still don't have any idea about how to do this.
    Thanks a lot...

    HongHong -
    There may be some tips you can use on www.77new.cn/program/i/1173293079453/001/029/14438.html -- I don't know chinese and the translation wasn't good enough for me to be sure about it.
    Have you tried? If your emulator or handset allows you to key in Chinese characters in a textField, they should be available via getString()and the resulting string should get stored OK, of course being a DBCS there wll be 2 bytes per letter.
    Recover the string from the RecordStore using
    new String(recordStore.getRecord(n));I have a MotoROKR E6 with alternative Chinese keyboard, shall experiment and get back to you in a day or two.
    Meanwhile, try for yourself and post the results.
    Regards, Darryl

  • Recordstore backup

    Hi,
    I want to backup my recordstore data on my PC using the P900 with CLDC 1.0, MIDP 2.0
    So far the only possibilities I see is:
    - Backup the phone
    - make a http connection and backup on the remote server
    - make a bluetooth connection to my PC
    Are there any other, "simple" possibilites?
    Can I not simply copy the recordstore files from my mobile phone to my PC (where are they stored)?
    Thanks for your help
    Bernhard

    Hi together,
    thanks a lot for your answers, with your help I managed to do the backup.
    I use FileMan http://www.symbianware.com/product.php?id=fileman_p800&pl=se_p900 and just have to copy these two files:
    \system\MIDIlets\RMSProtectionFile
    \system\MIDIlets\<strange number>\rms.db
    I tested the backup and it was working fine!
    Cheers
    Bernhard

  • RecordStore??

    I have a program that works as text entry system, i created it using canvas. It just like the normal typing program (not T9 dictionary), except it store words that is not existed in the RecordStore and use it as a suggestion, the next time user type with the same prefix.Suggestions appear in a box in the center of the canvas. I don't know what is wrong with the program. It runs but doesn't give any word suggestion. Can anyone please check the code for me.?
    Edited by: avaJ on Mar 20, 2008 1:08 PM

    PLEASE IGNORE THE PREVIOUS CANVAS CLASS, I FORGOT TO ADD SOMETHING ON THAT CLASS
    This is the My Canvas Class.. It takes input from users and draw the characters on the screen.
    This class calls some method from RSWord class to do queries, add new data, and update data.
    whenever user typed a letter, the program check whether word that started with that letter existed in RecordStore or not?
    if yes it will retrieve the top 5 words(with the highest frequency of use) and show it in a box,
    users may select the word by pressing the number associated to the order of the word inside the box, frequency of the suggested word that is selected by the user will be incerased by 1 and updated to recordStore.
    if the words with that prefix is not existed, the program will wait until user pressed space, then it will recognized the typed letter as a word and add it to the record store
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package textEntry;
    import java.io.IOException;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.*;
    import java.util.*;
    import javax.microedition.rms.RecordStoreException;
    * @author Ed's
    public class MyCanvas extends GameCanvas {
        public String[] keys = regularKey;
         public static final String[] regularKey =
        {".?!,@`-_:;()&\'\"~10�$��+x*/\\|[]=<>#","abc", "def", "ghi", "jkl",
        "mno", "pqrs", "tuv", "wxyz"};
        public static final String[] capitalKey =
        {".?!,@`-_:;()&\'\"~10�$��+x*/\\|[]=<>#","ABC", "DEF", "GHI", "JKL",
        "MNO", "PQRS", "TUV", "WXYZ"};
        public static final String[] numbKey = {"1,2,3,4,5,6,7,8,9"};
        StringBuffer width = new StringBuffer();
        public StringBuffer sms;    // hold the whole sms text
        public StringBuffer word; //hold the current typed, per word basis, new buffer created to replace the old one if space pressed
        wordRS db;
        Timer keyTimer;
        textEntryMain main;
        Vector suggestedVector;
        public static char ch;
        public boolean keypress=false;
        public boolean capital;
        public boolean diffrentKey;
        public char last;
        public boolean dontPrint=true; //dont print if timer printed or it is at begining
        public boolean first; //first char entered
        public boolean enteredNew=false; // if the entered is new word
        public boolean sBoxAppeared=false;
        public boolean notPrintingSuggestion=true;
        public boolean notInDatabase=false; //if true the queried word not in the database until space pressed it will stay true
        String currentIndicator="abc";
        String oneWord; // word string buffer that has been converted to string
        int countPress=0;
        int zeroPress=0;
        int sWordIndex=0;
        //int previndex=0;
        public int counter=-1;
        int index=-1;
        int print=0;
        int white_space=6;
        //var for draw rect
        int x, y;
        int baseline=10;
        int y_axis=12;
        int line=1;
        String justPressed;
        int prevPressed;
        char prevChar;
        Font font;
        public long time;
        //Char Selection speed
        private int selection_speed=150;
        //font color (blue)
        private int red=0,green=0,blue=255;
        //Background color (white)
        private int back_red=250,back_green=250,back_blue=250;
        Form menu;
        public MyCanvas(){
            super(false);
            first=true;
    //       this.main=main;
            sms=new StringBuffer();
            word= new StringBuffer();
            Graphics g=getGraphics();
            font=Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD,Font.SIZE_LARGE);
            keyTimer = new Timer ();
            keyTimer.schedule (new timerTask (this),500, selection_speed);
            drawIndicator(currentIndicator);
            try{db = new wordRS();} catch(RecordStoreException rse){rse.printStackTrace();}
        public void submitQuery(){
            if(!notInDatabase){
            try{
                suggestedVector = db.getSuggestion(oneWord);
            catch(RecordStoreException rse){
                rse.printStackTrace();
            if(suggestedVector.size()>0){
                drawSBox(); //call the draw box & and draw the suggested Suggested word.
                sBoxAppeared=true;//sBoxAppear=true
                drawSWords();
            else{
                notInDatabase=true; //set booleean to indicate that the word is not exsisted in the database
       public boolean notBegining(){
           if(baseline == 10 && line == 1){return false;}
           else {return true;}
        public void drawIndicator(String indicator){
            Font f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_SMALL);
            Graphics g = getGraphics();
            g.setFont(f);
            int x= getWidth()-20;
            g.setColor(back_red,back_green,back_blue);
            g.fillRect(x,2,15,10);
            g.setColor(20,20,20);
            g.drawString(indicator, x, 2, g.TOP|g.LEFT);
        public void addNewWord(){
            if(word.length()>0){ //only when the word buffer is not empty
                try {
                    db.addRecord(oneWord); 
                catch (RecordStoreException ex) {ex.printStackTrace();}
                catch (IOException ex) {ex.printStackTrace();}
        public void delFromWord(){
            if(word.length()>0){
            word.deleteCharAt(word.length()-1);
            oneWord = word.toString();
        public void callPaint(char ch){
            drawIndicator(currentIndicator);
            Graphics g= getGraphics();
            g.setColor(back_red,back_green,back_blue);
            if(first){
                g.fillRect(0,0,getWidth(),getHeight());
                reset();
                redrawAll();
                first=false;
            //baseline -1 so that i can cover the pointer
            g.fillRect(baseline-1,y_axis,font.charWidth(this.last)+3,font.getHeight());
            g.setColor(red,green,blue);
            g.setFont(font);
            g.drawChar(ch,baseline,line*24,g.LEFT|g.BASELINE);
            flushGraphics();
        public void showPointer(){
            Graphics g = getGraphics();
            g.setColor(0,0,0);
            g.drawLine(baseline,y_axis,baseline,2*line*12);
            flushGraphics();
        //pointer appear //pointer disappear-use white line so that it cover the pointer line
        public void hidePointer(){
            Graphics g = getGraphics();
            g.setColor(back_red,back_green,back_blue);
            g.drawLine(baseline,y_axis,baseline,2*line*12);
            flushGraphics();
        //draw the selected
        public void ConfirmPaint(char ch){
            Graphics g = getGraphics();
            sms.append(ch);
            if(notPrintingSuggestion){addToWord();} //ad the char to the string buffer that holds the word
            g.setColor(red,green,blue);
            g.setFont(font);
            g.drawChar(ch,baseline,line*24,g.LEFT|g.BASELINE); //draw the selected
            baseline+=font.charWidth(ch); // so that the nect letter won't be drawn on the same position
            if(baseline>getWidth()-30){     //move to the next line
                width.append((char)baseline);
                baseline=10;y_axis+=24;
                line+=1;
            flushGraphics();
            if(sms.charAt(sms.length()-1)==' '){
                submitQuery();
        public void addToWord(){
            word.append(ch);
            oneWord = word.toString();
        public void drawSelectedSuggestion(int Index){
            notPrintingSuggestion=false;
            StringBuffer selectedWord = (StringBuffer) suggestedVector.elementAt(Index);   
            for(int i= word.length(); i<=selectedWord.length(); i++){
                char sChar = selectedWord.charAt(i-1);
                ConfirmPaint(sChar);
            notPrintingSuggestion=true;
        public synchronized void deleteChar(){
            if(sms.charAt(sms.length()-1)==' '){ //if the previous character is space
                baseline-=white_space;
                Graphics g= getGraphics();
                g.setColor(back_red,back_green,back_blue);
                g.fillRect(baseline,y_axis,font.charWidth(sms.charAt(sms.length()-1))+2,font.getHeight());
                sms.deleteCharAt(sms.length()-1);
                delFromWord();
            else{
                baseline-=font.charWidth(sms.charAt(sms.length()-1));
                Graphics g= getGraphics();
                g.setColor(back_red,back_green,back_blue);
                g.fillRect(baseline,y_axis,font.charWidth(sms.charAt(sms.length()-1))+2,font.getHeight());
                delFromWord();
            flushGraphics();
        public void redraw(char ch ){
            Graphics g= getGraphics();
            g.setColor(red,green,blue);
            g.setFont(font);
            g.drawChar(ch,baseline,line*24,g.LEFT|g.BASELINE);
            baseline+=font.charWidth(ch);
            if(baseline>getWidth()-30){
                width.append((char)baseline);
                baseline=10;y_axis+=24;
                line+=1;
            flushGraphics();
        public void reset(){
            if(width.length() >0)
            width.delete(0,width.length()-1);
            line=1;
            baseline=10;y_axis=12;
        public void redrawAll(){
            Graphics g=getGraphics();
            g.setColor(back_red,back_green,back_blue);
            g.fillRect(0,0,getWidth(),getHeight());
            reset();
            for(int a=0;a<sms.length();a++)
            redraw(sms.charAt(a));
        public void drawSBox(){
            Graphics g = getGraphics();
            g.setColor(0,0,0);
            x=getWidth()/2-getWidth()/6;
            y=y_axis+20;
            g.drawRect(x , y, getWidth()/3, font.getHeight()*5+40);
            sBoxAppeared=true;
            flushGraphics();
        public void hideSBox(){
            Graphics g = getGraphics();
            g.setColor(back_red,back_green,back_blue);
            x=getWidth()/2-getWidth()/6;
            y=y_axis+20;
            g.fillRect(x , y, getWidth()/3, font.getHeight()*5+40);
            sBoxAppeared=false;
            flushGraphics();
        public void drawSWords(){
            int X= x+5;
            int Y= y+4;
            Graphics g = getGraphics();
            g.setColor(red, green, blue);
            for(int i=0; i<5; i++){
                g.drawString((i+1)+(String)suggestedVector.elementAt(i), X, Y, g.BASELINE|g.HCENTER);
                Y=Y+10;
        public synchronized void keyPressed (int keyCode) {
            hideSBox();// if user keep preessing without choosing hide the suggestionBox
            justPressed=getKeyName(keyCode);
            time=System.currentTimeMillis(); // record the time when the keypress is pressed
            if(justPressed.equalsIgnoreCase("NUM0")){ //caps lock show indicator
                if(zeroPress == 0){
                    currentIndicator="ABC";
                    zeroPress++;
                    keys=capitalKey;
                    drawIndicator(currentIndicator);
                    //set the string buffer to another one
                if(zeroPress == 1){
                    currentIndicator="123";
                    zeroPress++;
                    keys=numbKey;
                    drawIndicator(currentIndicator);
                if(zeroPress == 2){
                    currentIndicator="abc";
                    zeroPress=0;
                    keys=capitalKey;
                    drawIndicator(currentIndicator);
            if(justPressed.equalsIgnoreCase("SEND")){ //send button allocated as clear button
                if(sms.length()>0){
                    hidePointer();
                    if(baseline<=10){
                        System.out.println(baseline);
                        line-=2;
                        baseline=(int)width.charAt(line);
                        line++;
                        y_axis-=24;
                    deleteChar();
            if(keyCode==42){//35
                    if(notBegining()){
                    hidePointer();
                    sms.append(" ");
                    baseline+=white_space;
                    prevPressed=keyCode;
                    showPointer();
                    if(notInDatabase){addNewWord();}
                    notInDatabase=false;
                    word = new StringBuffer(); //if space just pressed reset the buffer coz the next letter should be belong to new word
            else{
                index=keyCode-49;
                //ACCEPTING USER KEYPRESS TO SELECT THE SUGGESTED WORD --START
                if(sBoxAppeared && index<=4){ 
                    drawSelectedSuggestion(index);
                    db.updateFrequency(index);
                    sBoxAppeared=false;
                    word = new StringBuffer();
                 //ACCEPTING USER KEYPRESS TO SELECT THE SUGGESTED WORD --STOP
                else{
                    int limit = 0;
                    keypress=true;
                    if(index==0){limit=34;}
                    if(index==1 || index==2 || index == 3 || index == 4
                    || index ==5 || index==7){ limit=3;}
                    if(index==6 || index==8){ limit=4;}
                    if(keyCode == prevPressed || dontPrint){ //dontPrint: timer excecuted confirmpaint so counterPress has to be reseted
                       if(dontPrint){countPress=limit+1;}
                       if(countPress<limit){
                           MyCanvas.ch=keys[index].charAt(countPress);
                           callPaint(MyCanvas.ch);
                           countPress++;
                        else{
                           countPress=0;  
                           MyCanvas.ch=keys[index].charAt(countPress);
                           callPaint(MyCanvas.ch);
                           countPress++;
                        dontPrint=false;
                    else{ //this is executed when the key is not repeated (prev!=)
                        ConfirmPaint(last);
                        countPress=0;  
                        MyCanvas.ch=keys[index].charAt(countPress);
                        callPaint(MyCanvas.ch);
                        countPress++;
                    last=MyCanvas.ch;
                    prevPressed=keyCode;
        public void closeDB() throws RecordStoreException
        {db.closeRS();}//this method destroy the enumeration and close the database
             /*   THIS IS FOR NUMB if(currentIndicator.equals("123")){
                    MyCanvas.ch=keys[index].charAt(0);
                    ConfirmPaint(ch);
                else{
    //task class for schedule on constructor

  • CF Card/SD Card storage location in JavaME SDK

    Hi All,
    I am using JavaMe SDK(not WTK). I need to access CF card. Earlier when I was using WTK I used to keep it in appdb/filesystem/root1/ folder. But I cannot find any such folder in JavaME SDK. I can find only one 'root1' folder in my SDK installation location. But that seems like not correct one. I am using DefaultFX touch phone profile.
    Please help me.
    Thanks DM

    Any help....?
    Thanks in advance
    D M

  • Reading the contactlist without PIM ,RecordStore and APDU

    Hi,
    I was playing with a commercial midlet and i discovered something strange.
    The midlet does not import the contact list using PIM ,the recordstore functions or the APDU protocol!
    How is that possible?
    I tried for example to use the RecordStore.listRecordStores() but of course I can't see the SIM contact list.
    Hence the window that allow the user to choose from the contact list has an icon which is not present in the icon directory of the jar and nor in the resource bin.
    Is it calling a special funciont that enable a window to select the contacts?
    Anybody can help me to understand this trick?
    The midlet is configured as:
    MIDP 1.0 and CLDC 1.0
    The package imported are:
    lcdui and recordstore

    I found that the JSR 185 specification allow this functionality but only for MIDP 2.0.
    Reading the documentation:
    Devices usually have a contact list, a place where the user may enter the names and phone numbers of people they know. To simplify building text messaging applications, JSR 185 requires that this phone book be available to populate TextField or TextBox components.
    But where can I find an example on how to use that fantastic component?

  • Problem with RecordStore.deleteRecordStore

    since rms doesnt have a recordstorerename function i have to copy all records to a new recordstore and delete the old one.
    the problem is that i need to close the from recordstore twice or i get a
    recordstore is still open exception.
    anyway to fix this ?
    RecordStore from = RecordStore.openRecordStore("thestore", false);
    RecordStore to = RecordStore.openRecordStore(tb.getString(), true);
    for (int i=1;i<=from.getNumRecords();i++) {
    byte[] data = from.getRecord(i);
    to.addRecord(data,0,data.length);
    to.closeRecordStore();
    from.closeRecordStore();
    from.closeRecordStore();
    RecordStore.deleteRecordStore("thestore");

    Hello,
    I checked this with WTK 2.2, but as expected I got the Exception RecordStoreNotOpenException, if I try closing the record store twice times.
    I think you just opened the record store once before and forgot to close it. MIDP2 says: 'MIDlet needs to make a balanced number of close calls as open calls before the record store is closed. ' And this applies to one RecordStore only.
    So have a look at your code and check this.

  • JavaME SDK 3, touch support on MSA phone.

    Hi,
    is there a way to enable touch support on
    JavaME SDK 3 using MSA phone?
    Before, we can edit this file DefaultCldcMsaPhone.properties
    to enable touch supports but now there is no option to enable touch in that file...
    Please help.

    All the phones in SDK 3.0 come back with true. Really bad and stupid.
    Testing with the WTK via netbeans, it works and I've looked though all the .properties files with no joy.
    stupid... and of course this thread is 8 months old and still no fix.

Maybe you are looking for

  • How do I print from my iPad to a USB printer on my time capsule?

    I have a Mac mini, iPad 2, iPad 3rd gen, 2 iPhone 5's, and a 2TB time capsule. All running the latest versions of their respective OS's. The hp printer I got at apple is plugged into the USB port on the time capsule because I couldn't figure out how

  • Hp Color LaserJet CP2025n printing a yellow band down the right hand side,

    I have a Hp Color LaserJet CP2025n running on a Desk top computer OS win 7 64bit, printer Serial Number [edited Serial Number by Moderator] and another number on the label CB494A, The printer has started printing a yellow band 1.5 cm wide all the way

  • Board game - pawn help.. I need some experts here.. i need this now.. beg..

    i have these whole junk of coding here.. where should i insert my pawns? lets say pinkpawn.jpg is my pawn.. then what code should i type & at where? import java.util.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.uti

  • Test Email Notifications

    Hi All, In Version 9.3.1, inside Workspace, there is a provision in Notifications to test if emails are being sent properly through the SMTP configuration. However, in Version 11.1.1.3, I could not find the same option in Notifications tab in Workspa

  • Xml parsers supported by JAXP1.1

    I'd like to know the xml parsers and their versions supported by JAXP1.1. although crimson.jar is the default parser provided, but i want to use a different parser. I need the answers urgently, Thanks.