Package javax.microedition.rms

Examples of javax.microedition.rms.RecordStore


        this.temperature=temperature;
        this.pressure=pressure;
    }
    public void saveToDataBase ()
    {
        RecordStore recordStore;
        DataOutputStream outputStream;
        try {
            recordStore = RecordStore.openRecordStore("locationPrefer", true);
        } catch (RecordStoreException rsc) {
            return;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        outputStream = new DataOutputStream(baos);
        try {
            outputStream.writeUTF(location);
            outputStream.writeFloat(latitude);
            outputStream.writeFloat(longitude);
            outputStream.writeByte(timeZoneSrc);
            outputStream.writeShort(timeZoneMin;
            outputStream.writeBoolean(isDSTOn);
            outputStream.writeShort(altitude);
            outputStream.writeShort(temperature);
            outputStream.writeShort(pressure);
            byte[] bytes = baos.toByteArray();
           
            if (recordStore.getNumRecords() == 0)
                recordStore.addRecord(bytes, 0, bytes.length);
            else
                recordStore.setRecord(1, bytes, 0, bytes.length);
        } catch (Exception exception) {
        } finally {
            try {outputStream.close();} catch (Exception ex) {}
            try {recordStore.closeRecordStore();} catch (Exception ex) {}
        }
    }
View Full Code Here


            try {outputStream.close();} catch (Exception ex) {}
            try {recordStore.closeRecordStore();} catch (Exception ex) {}
        }
    }
    public void loadFromDataBase() {
        RecordStore recordStore = null;
        DataInputStream inputStream = null;
        try {
      recordStore = RecordStore.openRecordStore("locationPrefer", false);
            byte[] bytes = recordStore.getRecord(1);
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            inputStream = new DataInputStream(bais);
            location = inputStream.readUTF();
            latitude = inputStream.readFloat();
            longitude = inputStream.readFloat();      
            timeZoneSrc=inputStream.readByte();
            timeZoneMin = inputStream.readShort();
            isDSTOn=inputStream.readBoolean();
            altitude=inputStream.readShort();
            temperature=inputStream.readShort();
            pressure=inputStream.readShort();
                 
        } catch (Exception ex) {
            location ="İstanbul";
            latitude =41.02f;
            longitude = 28.97f;
            timeZoneSrc=1;//0;
            timeZoneMin =120;
            isDSTOn=false;
            altitude=0;
            temperature=10;
            pressure=1010;
            isItFirstTime=true;

           
        } finally {
            try {inputStream.close();} catch (Exception ex) {}
            try {recordStore.closeRecordStore();} catch (Exception ex) {}
        }
    }
View Full Code Here

  public static Image[] MUCUS_IMAGES = null;
 
  private MucusRegistry() throws IOException, RecordStoreException {
    Log.log("MucusRegistry.MucusRegistry()");
    try {
      RecordStore rms = RecordStore.openRecordStore(MUCUS_REGISTRY, false);
      registry = MucusUtils.getAll(rms);
      rms.closeRecordStore();
     
    }catch(RecordStoreNotFoundException ex){
      registry = MucusUtils.createDefaultsVector();
    }
    Log.log("MUCUS_IMAGES 1="+MUCUS_IMAGES);
View Full Code Here

    private static final String DEFAULT_PAUSE_CHAR = "p";

    public static void initialize() throws IOException
    {
        settings.cl = cl;
        RecordStore rs = null;
        try {
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if (rs.getNumRecords() != 0) {
                String[] settingsStr = serial.deserialize(numFields, rs.getRecord(1));
                setSettings(settingsStr);
                if (rs.getNumRecords() == 2) {
                    byte[] data = rs.getRecord(2);
                    recentContacts = serial.deserializeKVPVector(MAX_CONTACTS, data);
                }
            }
        } catch (RecordStoreException ex) {
            Logger.add("settings", "initialize", ex.getMessage());
            ex.printStackTrace();
        }
        finally{
            try{
                rs.closeRecordStore();
            }
            catch(Exception ignore){}
        }
    }
View Full Code Here

        }
    }

    public static void updateContacts() throws RecordStoreException, IOException
    {
        RecordStore rs = null;
        try{
            byte[] data = serial.serializeKVPVector(getRecentContacts());
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if(rs.getNumRecords() != 0){
                try{
                    rs.setRecord(2, data, 0, data.length);
                }
                catch(InvalidRecordIDException ire)
                {
                    rs.addRecord(data, 0, data.length);
                }
            }
        }
        catch(RecordStoreException rse)
        {
            Logger.add("settings", "updateSettings", rse.getMessage());
            rse.printStackTrace();
        }
        finally{
            try{
                rs.closeRecordStore();
            }
            catch(Exception ignore){}
        }
    }
View Full Code Here

        }
    }

    public static void updateSettings() throws RecordStoreException
    {
        RecordStore rs = null;
        try{
            String[] fields = {username, password, interval, callFrom, pin, gvNumber, pauseChar, String.valueOf(callWith)};
            byte[] data = null;
            data = serial.serialize(fields);
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if(rs.getNumRecords() != 0)
            {
                rs.setRecord(1, data, 0, data.length);
            }
            else
            {
                rs.addRecord(data, 0, data.length);
            }
        }
        catch(Exception ex)
        {
            Logger.add("settings", "updateSettings", ex.getMessage());
            ex.printStackTrace();
        }
        finally{
            rs.closeRecordStore();
        }
    }
View Full Code Here

    private static Vector recentContacts;

    public static void initialize() throws IOException
    {
        settings.cl = cl;
        RecordStore rs = null;
        //getRecentContacts() = new Vector();
        try {
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if (rs.getNumRecords() != 0) {
                String[] settingsStr = serial.deserialize(numFields, rs.getRecord(1));
                setSettings(settingsStr);
                if (rs.getNumRecords() == 2) {
                    byte[] data = rs.getRecord(2);
                    recentContacts = serial.deserializeKVPVector(MAX_CONTACTS, data);
                }
            }
        } catch (RecordStoreException ex) {
            Logger.add("settings", "initialize", ex.getMessage());
            ex.printStackTrace();
        }
        finally{
            try{
                rs.closeRecordStore();
            }
            catch(Exception e)
            {}
        }
    }
View Full Code Here

        }
    }

    public static void updateContacts() throws RecordStoreException, IOException
    {
        RecordStore rs = null;
        try{
            byte[] data = serial.serializeKVPVector(getRecentContacts());
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if(rs.getNumRecords() != 0){
                try{
                    rs.setRecord(2, data, 0, data.length);
                }
                catch(InvalidRecordIDException ire)
                {
                    rs.addRecord(data, 0, data.length);
                }
            }
        }
        catch(RecordStoreException rse)
        {
            Logger.add("settings", "updateSettings", rse.getMessage());
            rse.printStackTrace();
        }
        finally{
            try{
                rs.closeRecordStore();
            }
            catch(Exception e)
            {}
        }
    }
View Full Code Here

        }
    }

    public static void updateSettings() throws RecordStoreException
    {
        RecordStore rs = null;
        try{
            String[] fields = {username, password, interval, callFrom};
            byte[] data = null;
            data = serial.serialize(fields);
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if(rs.getNumRecords() != 0)
            {
                rs.setRecord(1, data, 0, data.length);
            }
            else
            {
                rs.addRecord(data, 0, data.length);
            }
        }
        catch(Exception ex)
        {
            Logger.add("settings", "updateSettings", ex.getMessage());
            ex.printStackTrace();
        }
        finally{
            rs.closeRecordStore();
        }
    }
View Full Code Here

    private static Vector recentContacts;

    public static void initialize() throws IOException
    {
        settings.cl = cl;
        RecordStore rs = null;
        //getRecentContacts() = new Vector();
        try {
            rs = RecordStore.openRecordStore(userSettingsStore, true);
            if (rs.getNumRecords() != 0) {
                String[] settingsStr = serial.deserialize(numFields, rs.getRecord(1));
                setSettings(settingsStr);
                if (rs.getNumRecords() == 2) {
                    byte[] data = rs.getRecord(2);
                    recentContacts = serial.deserializeKVPVector(MAX_CONTACTS, data);
                }
            }
        } catch (RecordStoreException ex) {
            Logger.add("settings", "initialize", ex.getMessage());
            ex.printStackTrace();
        }
        finally{
            try{
                rs.closeRecordStore();
            }
            catch(Exception e)
            {}
        }
    }
View Full Code Here

TOP

Related Classes of javax.microedition.rms.RecordStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.