Deleting RecordStore..

when I try to delete RecordStore with
RecordStrore.deleteRecordStore("recordstorename");
it gives RecordStoreNotOpen Exception. record store still open
-> could any one suggest me a way to get rid of this problem. so tht if recordStore is already open by any process , close it first and delete the records..??

Yes

Similar Messages

  • Cannot Delete RecordStore although RecordStore is closed already

    Hi... my class has 2 methods which 1 of them saves image to RecordStore and the other one loads the saved image from RecordStore. In some conditions, some of the saved images need to be deleted from the RecordStore.
    Well, i keep getting "javax.microedition.rms.RecordStoreException: deleteRecordStore error: record store is still open". I'm pretty sure i have closed the RecordStore but it just can't be deleted.
    Below is the excerpt of my code. Since my original code is very long, i just enter the 3 relevant methods. Please kindly help. :)
      //A function to load image from the memory
        public Image LoadImage(int width, int height, String imageCid) throws RecordStoreException {
          rs = RecordStore.openRecordStore(imageCid, true);
            byte[] b = null;
            String imagename = null;
            Image image = null;
            if (rs.getNumRecords() > 0) {
                try {
                    int i = rs.getNumRecords();
                    for(int j = 1; j < i + 1; j++) {
                        if(rs.getRecord(j) != null) {
                            b = rs.getRecord(j);
                            ByteArrayInputStream  bin =
                                new ByteArrayInputStream( b );
                            DataInputStream   din = new DataInputStream( bin );
                            imageCid = din.readUTF();
                            int remaining =
                                (b.length-imageCid.getBytes().length-2)/4;
                            int[] rawdata = new int[remaining];
                            for(int k =0 ;k<rawdata.length ;k++) {
                                rawdata[k] = din.readInt();
                            image = Image.createRGBImage(rawdata,
                                width, height, false);
                            bin.reset();
                            din.close();
                            din =null;
                } catch (IOException e) {
                    e.printStackTrace();
                } catch(RecordStoreException recordstoreexception) {
                    recordstoreexception.printStackTrace();
                finally {
                    System.out.println("Banner LoadImage - closing RecordStore of " + imageCid);
                     rs.closeRecordStore();
                     rs = null;
            return image;
    //A function to save image to the memory of the device
        public boolean SaveImage (Image img, int width,
                int height, String imageCid) throws RecordStoreException {
              rs = RecordStore.openRecordStore(imageCid, true);
            if (img == null || width < 0 || height < 0 || imageCid == null) {
                throw new IllegalArgumentException("Check arguments");
            int[] imgRgbData = new int[width * height];
            try {
                img.getRGB(imgRgbData, 0, width, 0, 0, width, height);
            } catch (Exception e) {
                // Problem getting image RGB data
                return false;
            try {
                // Write image data to output stream (in order to get
                // the record bytes in needed form)
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                DataOutputStream dos = new DataOutputStream(baos);
                dos.writeUTF(imageCid);
                for (int i = 0; i < imgRgbData.length; i++) {
                    dos.writeInt(imgRgbData);
    // Open record store, create if it doesn't exist
    rs.addRecord(baos.toByteArray(), 0,
    baos.toByteArray().length); // Add record
    } catch (RecordStoreNotFoundException rsnfe) {
    // Record storage not found
    System.out.println("Banner SaveImage - RecordStoreNotFound");
    System.out.println("Banner SaveImage - closing RecordStore of " + imageCid);
    rs.closeRecordStore();
    rs = null;
    return false;
    } catch (RecordStoreException rse) {
    // Other record storage problem
    System.out.println("Banner SaveImage - RecordStoreNotException");
    System.out.println("Banner SaveImage - closing RecordStore of " + imageCid);
    rs.closeRecordStore();
    rs = null;
    return false;
    } catch (IOException ioe) {
    // Problem writing data
    System.out.println("Banner SaveImage - IOException");
    System.out.println("Banner SaveImage - closing RecordStore of " + imageCid);
    rs.closeRecordStore();
    rs = null;
    return false;
    System.out.println("Banner SaveImage - closing RecordStore of " + imageCid);
    rs.closeRecordStore();
    rs = null;
    System.out.println("Banner SaveImage - OK");
    return true; // We've successfuly done
    //Delete stored image based on campaignId
    private void DeleteStoredImage (String imageCid) throws RecordStoreException {
    if (RecordStore.listRecordStores() != null) {
    RecordStore.deleteRecordStore(imageCid);

    I don't know if it's still relevant, but cut there be a situation where you open the recordstore and don't close it? Because when you open the same recordstore twice and close it just one time then you can get this exception... I see you open the recordstore outside the try block and close it in the finally block. so just looking at your if condition makes it pretty clear that when you have no records in your recordstore and you try to load the images, then the RMS doesnt get closed... and when you then try to delete it, it will give you the RecordStoreException... So best would be to put the try also around the openrecordstore method

  • Cant delete a recordstore

    Hi,
    I was wondering if their is anybody that can tell me why a record store that I have created cannot be deleted using the "RecordStore.deleteRecordStore( );" method.
    I have written a bit of code which when executed should delete the entire record store "PLAYERSTORE", but for some reason it does not.
    My code:
    public void deleteRecordStore()
              try
                   System.out.println("Store deleted");
                   RecordStore.deleteRecordStore( "PLAYERSTORE" );
              catch( RecordStoreNotFoundException e )
                   System.out.println("Exception: "+e);
              catch( RecordStoreException e )
                   System.out.println("Exception: "+e);
    At first i thought it might be because i hadnt closed the record store after using it in previous methods, unfortunatelly this was not the case.
    Please help

    Still no joy with deleting the record
    I think this is what you are looking for (StackTrace)...
    java.lang.NullPointerException
         at CourseListing.deleteRecord(+35)
         at CourseListing.commandAction(+49)
         at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
         at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
         at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
         at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)
    This is what is displayed when I try and delete a record
    I have posted the whole code listing bellow the "bold" code is the code that deletes a record
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.*;
    import java.util.*;
    import javax.microedition.rms.*;
    public class CourseListing extends List implements CommandListener
         private RecordStore rs;
         private GSAP midlet;
         private Command backCommand = new Command("Back", Command.BACK, 0);
         private Command deleteCommand = new Command("Delete", Command.SCREEN, 1);
         private Command viewCommand = new Command("View", Command.SCREEN, 1);
         private Ticker courseListing = new Ticker("The following is a list of courses stored by the GSAP. You have the option of, viewing course details, editing course details, or deleting a course entirely.");
         public CourseListing(GSAP midlet)
              super("COURSES", Choice.EXCLUSIVE);
              this.midlet = midlet;
              addCommand(backCommand);
              addCommand(deleteCommand);
              addCommand(viewCommand);
              setTicker(courseListing);
              setCommandListener(this);
              readRecords();
         public void readRecords()
              //Open COURSESTORE record store
              RecordStore rs = null;
              try
                   rs = RecordStore.openRecordStore("COURSESTORE", true);
                   System.out.println("COURSESTORE open");
              catch(RecordStoreNotFoundException rsnfe)
                   System.out.println("The record store you are trying to open does not exist :"+rsnfe);
              catch(RecordStoreFullException fsfe)
                   System.out.println("The record store cannot store anymore data :"+fsfe);
              catch(RecordStoreException rse)
                   System.out.println("An error has occured when using the record store :"+rse);
              //Read records from the PLAYERSTORE and store in an array
              try
                   byte[] recData = new byte[5];
                   int records;
                   System.out.println("At the for loop");
                   for (int i = 1; i <= rs.getNumRecords(); i++)
                        System.out.println("Inside for loop");
                        // Allocate more storage if necessary
                        if (rs.getRecordSize(i) > recData.length)
                        recData = new byte[rs.getRecordSize(i)];
                        records = rs.getRecord(i, recData, 0);
                        //System.out.println(rs.getRecord(i, recData, 0));
                        System.out.println("Record ID#" + i + ": " + new String(recData, 0, records));
                        //append("Record ID#" + i + ": " + new String(recData, 0, records), null);
                        append(""+ new String(recData, 0, records), null);     
              catch (Exception e)
                   System.err.println(e.toString());
              //Close the record store
              try
                   rs.closeRecordStore();
              catch( RecordStoreNotOpenException e )
                   System.out.println("Record store already closed!");
              catch( RecordStoreException e )
                   System.out.println("Exception:"+e);
         public void commandAction(Command c, Displayable d)
              if(c == backCommand)
                   midlet.courseMenuScreenShow();
              else if(c == viewCommand)
                   System.out.println("View the selected course details");
              else if(c == deleteCommand)
                   deleteRecord();
                   System.out.println("The selected course will be deleted");
              else
                   processMenu();
         private void processMenu()
              try
                   List down = (List)midlet.display.getCurrent();
                   switch(down.getSelectedIndex())
                        case 0: midlet.addCourseScreenShow();
                        case 1: System.out.println("Manage courses");
              catch(Exception ex)
                   System.out.println("processMenu::"+ex);
         public void deleteRecord()
              try
                   int id = 1;
                   System.out.println("WE ARE HERE NOW");
                   rs.openRecordStore( "PLAYERSTORE", true );
                   System.out.println("WE ARE HERE NOW FOR GOODNESS SAKE");
                   rs.deleteRecord(id);
                   System.out.println("WE ARE HERE NOW FOR GOODNESS SAKE OHHH YEAH");
              catch(RecordStoreNotOpenException e)
                   System.out.println("Exception: "+e);
              catch(InvalidRecordIDException e)
                   System.out.println("Exception: "+e);
              catch( RecordStoreException e )
                   System.out.println("Exception:"+e);
                   e.printStackTrace();
              //Close the record store
              try
                   rs.closeRecordStore();
              catch( RecordStoreNotOpenException e )
                   System.out.println("Record store already closed!");
              catch( RecordStoreException e )
                   System.out.println("Exception:"+e);
         }//End of deleteRecord() method     
    }

  • Delete existing RecordStore and then open a newer one with same name

    Hey All,
    I'm working in J2Me for Nokia S40 DP2.0 SDK 1.0.
    I want to delete my existing RecordStore (i. e; Products) and then open a new RecordStore as same name(Products) But
    There is an Exception thrown that RecordStore is Open;
    my deletion process is given below :
    public void deleteRecStore(String recordName) {
    if (RecordStore.listRecordStores() != null) {
    try {        
    RecordStore.deleteRecordStore(recordName);
    } catch (Exception e) {
    e.printStackTrace();
    public void createRecStore(String recordName, Vector data, int insertType) {
    if(recordName.equals("") && (recordName != null)) {
    try {
    if(insertType == this.NEW_REC) {
    rs = RecordStore.openRecordStore(recordName,true);
    this.closeRecStore();
    this.deleteRecStore(recordName);
    rs = RecordStore.openRecordStore(recordName,true);
    Can anybody pls help me...
    why I can't open a new recordstore like this ??
    If there any process then what is that ???
    Rania...

    This question belongs in the [CLDC and MIDP forum|http://forums.sun.com/forum.jspa?forumID=76]. I'll move it there in an hour or so.
    I would suggest that in addition to printing the stack trace of any Exception, you could append the Exception.toString() to a Form (or display it in an Alert) to see whether any exceptions are being thrown.
    db

  • RecordStore: multiple stores, deletion and WTK

    Hi All,
    I've been playing around with record stores for a couple of days and have run into a couple of problems, which I think are related.
    First some background. I access the RecordStore methods from a instance of a class called MyRecordStore. In the class there are some methods to open and close stores, retrieve information and set information.
    At first I created a RecordStore called roundStore, which contained the number of rounds of a game that could be played. The store was called "rounds". All was fine!
    The problems started when I defined another RecordStore, called scoreStore:
    protected RecordStore roundStore = null; // works fine
    protected RecordStore scoreStore = null; // problems start here
    //In appropriate try/catch statements
    roundStore = RecordStore.openRecordStore("rounds", true);
    scoreStore = RecordStore.openRecordStore("scores", true);
    ScoreStore was supposed to contain the scores. However, when I ran the WTK I got the following error: javax.microedition.rms.InvalidRecordIDException
    To me it seemed that I could only have one store. However, when I later deleted roundStore (which had been working fine) and then tried to recreate it I got the same message invalidRecordIDException for roundStore. I then listed the stores on my system and both "scores" and "rounds" were listed - even after I thought I deleted them.
    Do the stores persist in the WTK even after they have been deleted and, if so, how can they be removed so that I can start afresh. BTW, I have tried to clean the WTK.
    Thanks if you can provide any help,
    Hugh
    I assume that

    Hi VC,
    Thanks for the information. I've been having problems with the record stores ever since I started deleting them. So I tried your suggestion, but I'm afraid no joy.
    I've even gone right back to the start, to where I thought that all was well and I'm still getting an "InvalidRecordIDException".
    To explain: I create an instance of MyRecordStore. In the MyRecordStore class I create an instance of the RecordStore class:
    RecordStore roundStore = null;
    Later on I open it, and create it if required
    protected void openRounds(){
         try
                   roundStore = RecordStore.openRecordStore("rounds", true);
              catch (RecordStoreException rse) {
                   System.out.println("RSE " + rse);
                   rse.printStackTrace();
    }//end of openRounds
    No exceptions yet. However, if I try to set a record an InvalidRecordIDException is thrown (b is a byte array):
    try {
                   recId = roundStore.getNextRecordID();
                   System.out.println("getNum " + String.valueOf(recId));
                   roundStore.setRecord(1, b, 0, b.length);// this line is the problem
    I can interrogate the store to get the next record ID, which returns 1.
    If anyone has any ideas on why I'm getting this error I would be pleased to hear from you.
    Many thanks,
    Hugh

  • Getting Problem after Deleting a record from Record Store

    I am trying to create a simple application for mobile device. This application storing some records. I used RMS for this. These records i show in a list. But i tried to show list of records after deleting any record then list shows only prior records of deleted records n then shows exception as
    Recordsjavax.microedition.rms.InvalidRecordIDException
    The code i written as follows
    For storing data
    public void storeExercise(String EName, String Etime)
    try
    //System.out.println("AAAA");
    recordstore = RecordStore.openRecordStore("Test3",true);
    catch (Exception error)
    //System.out.println("EEEE");
    System.out.println("Exception"+error);
    try
    byte[] outputRecord;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    DataOutputStream outputdataStream = new DataOutputStream(outputStream);
    outputdataStream.writeUTF(EName);
    outputdataStream.writeUTF(Etime);
    outputdataStream.flush();
    outputRecord = outputStream.toByteArray();
    recordstore.addRecord(outputRecord, 0, outputRecord.length);
    outputStream.reset();
    outputStream.close();
    outputdataStream.close();
    zlist.append(EName+Etime, null);
    display.setCurrent(zlist);
    catch (Exception error)
    System.out.println("Exception in writing Records"+error);
    for getting records
    public void getExercise(ZimList zlist)
    this.zlist = zlist;
    try
    //System.out.println("AAAA");
    recordstore = RecordStore.openRecordStore("Test3",true);
    //recordstore.closeRecordStore();
    catch (Exception error)
    //System.out.println("EEEE");
    System.out.println("Exception"+error);
    try
    //System.out.println("Hello");
    String Ename = null;
    String Etime = null;
    byte[] byteInputData = new byte[100];
    ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
    DataInputStream inputDataStream = new DataInputStream(inputStream);
    for (int x=1; x<= recordstore.getNumRecords() ; x++ )
    System.out.println("Record Id ="+x);
    //if (x != InvalidRecordID)
    recordstore.getRecord(x, byteInputData, 0);
    Ename = inputDataStream.readUTF();
    Etime = inputDataStream.readUTF();
    inputStream.reset();
    Final = Ename + Etime;
    System.out.println("Insert" + Final);
    zlist.insert(x-1,Final,null);
    inputStream.close();
    inputDataStream.close();
    //recordstore.closeRecordStore();
    catch (Exception error)
    System.out.println("Exception in Reading Records"+error);
    /*if (recordstore.listRecordStores() != null)
    try
    recordstore.deleteRecordStore("My Record Store");
    catch (Exception error)
    System.out.println("Exception"+error);
    And for deleting records I write
    public void deleteExercise(int index)
    try
    //System.out.println("AAAA");
    recordstore = RecordStore.openRecordStore("Test3",true);
    //recordstore.closeRecordStore();
    catch (Exception error)
    //System.out.println("EEEE");
    System.out.println("Exception"+error);
    if (recordstore.listRecordStores() != null)
    try
    byte[] byteInputData = new byte[100];
    ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
    DataInputStream inputDataStream = new DataInputStream(inputStream);
    for (int x=1; x<= recordstore.getNumRecords() ; x++ )
    recordstore.getRecord(x, byteInputData, 0);
    if (x == index)
    recordstore.deleteRecord(index);
    //x--;
    inputStream.reset();
    break;
    inputStream.close();
    inputDataStream.close();
    catch (Exception error)
    System.out.println("Exception in Deleting Records"+error);
    Please Help me bcz i am new in j2me development n having no experience

    Ok ...
    When you add records in you store, the J2ME implementation create an ID.
    In the database, there is a list like that with ID <--> ]byte[ ]
    You can get back a record with a this ID.
    When you delete a record, it deletes the row. Lets say you have stored 3 records and that the ID are 1, 2, 3 ... if you delete the second one, then you have still in the database IDs 1 and 3.
    That's why you have this exception : you are iterating with an ID 1, 2, 3, 4, 5 ... if one is delete there is no reorganization. (If you add an other record, it could be stored with ID 2).
    To read all the records, you should get a list of existing IDs. Take a look at the API. Here is a piece of code, that you work but I have not tested :
    RecordStore rs;
    RecordEnumeration re = rs.enumerateRecords(null, null, false);
    while (re.hasNextElement()) {
      String str = new String(re.nextRecord());
      System.out.println("Record: " + str);         
    } Hope it will help you.
    Regards

  • 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

  • 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.

  • Problem in RecordStore

    As we know that we have a method deleteRecord(int recordId) in RecordStore Class. it deletes the record ID associated with the record.
    So, when we delete a record, it deletes the record along with the recordID but does not rearrange the remaining records in the recordstore. we have to do it manually. i am using a logic to set the new recordID for the remaining records but it is not working well. So if you know how to solve this problem, please tell me....

    You cannot get the complete RDBMS kind of functionality incorporated in Java ME client since it is only a tiny foot-print provided to store bytes of information.
    Regarding your problem the record ID is treated as an primary key and once deleted cannot be retrieved back. Better to use setRecord() call instead.
    ~Mohan

  • Recordstore share problem

    the same package which is what i think means midlets in the same suite.Hi all..Can smone tell how do i share a recordstore between midlets in the same suite. I created two midlets 1)CreateRecord for storing records. 2)Getdata for retrieving records. i start with CreateRecord and close the record store in it after storing data but didnt delete the recordstore. Then i open the record store with the same name in getdata midlet and get an error exception IllegalAccessException.
    I have included both the midlets in
    Thanks in advance.

    Please be specific what you want to do ..
    --Senthil                                                                                                                                                                                                               

  • RecordStore confusion.

    Hi Everyone,
    My midlet creates new RecordStores if not already present, or opens it if it is already present and returns the object of RecordStore. I am maintaining these RecordStore objects in a hash table, Like...
            RecordStore rs = null;
            try {
                rs = RecordStore.openRecordStore(recordStoreName, true);
                rs.setMode(RecordStore.AUTHMODE_PRIVATE, false);
            } catch (RecordStoreException ex) {
                ex.printStackTrace();
            recStoreHT.put(recordStoreName, rs);If I fetch the object of RecordStore from the hash table, and close the fetched object, like...
         RecordStore rs = ((RecordStore)recStoreHT.get(recordStoreName));
         rs.closeRecordStore();then will it close only the local object rs? and not the object which is stored in hash table? Is the object in hash table still open?
    Actually, I am getting the RecordStoreException while deleting the record store. I got to know that I have to close carefully all the opened instances of the RecordStore. But I am very much confused as I am not getting what is going wrong. Please guide me and suggest me the ways to deal this exception.

    nikhil_shravane wrote:
    If I fetch the object of RecordStore from the hash table, and close the fetched object, like...
    RecordStore rs = ((RecordStore)recStoreHT.get(recordStoreName));
    rs.closeRecordStore();then will it close only the local object rs? and not the object which is stored in hash table? Is the object in hash table still open?Huh? They're the same object. Don't confuse objects and references.
    Actually, I am getting the RecordStoreException while deleting the record store. I got to know that I have to close carefully all the opened instances of the RecordStore. But I am very much confused as I am not getting what is going wrong. Please guide me and suggest me the ways to deal this exception.Read the API for closeRecordStore().
    Note that the record store will not actually be closed until closeRecordStore() is called as many times as openRecordStore() was called.
    db

  • RecordStore within choicegroup

    how to make a RecordStore within choicegroup?
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;
    import java.io.*;
    public class RMSDemo extends MIDlet implements CommandListener {
    private Display display;
    private RecordStore rs=null;
    private Command exit,add,delete, show;
    private RecordEnumeration re;
    private int recordNO;
    Form frm;
    int index=0;
    public RMSDemo() {
    display = Display.getDisplay(this);
    //Create a RMS
    try {
    rs= RecordStore.openRecordStore("myRecord",false);
    rs.closeRecordStore();
    } catch(Exception e) {
    System.out.println(e);
    public void startApp() {
    frm=new Form("RMSDemo");
    exit= new Command("Exit",Command.EXIT,1);
    frm.addCommand(exit);
    add= new Command("Add",Command.SCREN,1);
    frm.addCommand(add);
    delete= new Command("Delete",Command.SCREEN,2);
    frm.addCommand(delete);
    show= new Command("SHOW",Command.SCREEN ,3);
    frm.addCommand(show);
    frm.setCommandListener(this);
    frm.append("#####");
    display.setCurrent(frm);
    public void pauseApp() {
    public void destroyApp(boolean un) {
    // Handling commands
    public void commandAction(Command cmd,Displayable d) {
    if(cmd==add) {
    addRecord();
    } else
    if(cmd==delete) {
    removeRecord();
    } else
    if(cmd==show) {
    try {
    byte b[]= rs.getRecord(recordNO);
    String s= new String(b);
    frm.append(s);
    cg_sexo = new ChoiceGroup("Sexo.: ",ChoiceGroup.POPUP,s,null);
    } catch(Exception e) {}
    void addRecord() {
    try {
    rs= RecordStore.openRecordStore("myRecord",false);
    index++;
    byte b[]=("Record NO "+index).getBytes();
    //Adding record to record store
    rs.addRecord(b,0,b.length);
    rs.closeRecordStore() ;
    } catch(Exception e) {
    System.out.println(e);
    // Deleting a record
    void removeRecord(int recordID) {
    try {
    rs= RecordStore.openRecordStore("myRecord",false);
    rs.deleteRecord(recordID);
    index--;
    rs.closeRecordStore();
    } catch(Exception e) {
    System.out.println(e);
    Edited by: 876788 on 05-oct-2011 21:37

    Hi, first of all, I'd like to recommend you a package called Floggy instead of working with RMS directly, they also have great support on their forums.
    Secondly, why not simply create a new class and implement Persistable (if you'll choose Floggy later)?

  • J2ME MIDP4Palm reseting recordStore

    Hi all,
    I have a recordStore with many records in it. I have changed the way I pack and unpack my data aswell as some other small changes in my MIDlet.
    The problem is:
    I am getting 1 or 2 exceptions in my program. As a result of my MIDlet changing as I develop it, there are records in the recordStore that are not being read because the elements that each record holds has changed. I want to get rid of these "old" records and start off with a blank recordStore. These "old" records are throwing exceptions in my program making it very hard to debug!!
    Any ideas??
    Thanks,
    Liam C

    read the javadoc....
    public static void deleteRecordStore(String recordStoreName)
    throws RecordStoreException,
    RecordStoreNotFoundExceptionDeletes the named record store. MIDlet suites are only allowed to operate on their own record stores, including deletions. If the record store is currently open by a MIDlet when this method is called, or if the named record store does not exist, a RecordStoreException will be thrown.
    Parameters:
    recordStoreName - the MIDlet suite unique record store to delete.
    Throws:
    RecordStoreException - if a record store-related exception occurred.
    RecordStoreNotFoundException - if the record store could not be found.

  • RecordStore & PushRegistry interaction??

    Hi,
    I've got a strange problem.... My MIDlet has registred on a port to receive sms... If the appli is opened by reception of a SMS, it opens screen A. If it is opened manually, screen B is displayed. Until there, no problem...
    But when I try to open a recordStore in screen B, big problem!!! On reception of a SMS, the appli opens itself and displays screen B for 2 second instead of screen A and then closes. When I delete the recordStore part, everything works fine. I cannot show my code because this is more complicate and rather long...
    Has anyone ever seen this behaviour???
    Thanks,
    Isabelle

    I've found a way to avoid it. I launch the recordstore open in a new thread. And I have no more problem. But it does not explain everything....
    Isabelle

  • RMS Delete Record

    Hi,
    I have a RecordStore that store bytes of images. In this Record Store could be more than one images. When I delete one of this record it can happens that the avalaible size of the Record Store is the same of that before of delete although the record is deleted (the number of record in the Record Store is more small than 1) . This situation is not regullary because other times this doesn't happen: when I delete a record (with rs.deleteRecord(i)) the avalaible size grow up. Do you know bugs o particullary situation of RMS? Can you help me?

    Hi,
    When you delete a record youdont actually delete it but you set the contents for that record Id as null.
    i.e. The size of your recordstore will be the maximum number of records it ever held.
    Also if you delete a record, the records following will not be shifted up.
    i.e. if for record id
    1) Birds
    2) Bees
    3) Honey
    are the records in my recordstore then rs.deleteRecord(2) results in the following structure
    1) Birds
    2) <null>
    3) Honey
    Personally I use another recordstore to manage my data stores. However the correct method i believe is to use record enumeration. Cant help you with that. Shmoove is probably the best person to ask.

Maybe you are looking for

  • Updated to Lion and now iTunes and Apple TV 2 no longer work

    I "upgraded" to Lion today and now iTunes won't work and neither will my Apple TV 2. I click on media in iTunes and nothing happens. More than that, though, there's something strange going on with the metadata because movie posters are vanishing and

  • Sales Man wise Sales Report.

    Dear All, I need to develop the Report SalesMan Wise in the below format. *_SL No/Sales Man/Customer/Customer Name/Target of Current Year (Previous Year Sales1.35)/Jan Sales/Feb Sales./Mar Sales/Apr Sales/ till Aug Sales (2011 Year) i.e Last 7 Months

  • How To Uninstall Earlier Versions of Flash Player???

    Can anyone help?! I recently installed the latest version of Adobe Flash Player V. 10, and the instructions said it would be best to uninstall any earlier versions of the Player. I have 3 installations of Adobe Flash Player V. 9, and 1 installation o

  • How do u transfer pictures/tunes from 4 year old mac to new mac

    how do u transfer pictures/tunes from 4 year old mac to new mac ?

  • IT0009 configuration

    Hi, At present my client is not integrating payroll with PA, however they want to maintain the IT0009 to capture the bank country, bank key,a/c number, payment method and payment currency  globally. What are the steps I should take to maintain this i