Package javax.microedition.rms

Examples of javax.microedition.rms.RecordStore


public class StorageInRecordStores extends BaseStorage {
    protected byte[] data;

    public void open(String filename) throws IOException {
        try {
            final RecordStore store = RecordStore.openRecordStore(filename, false);
            try {
                data = store.getRecord(1);
                in = new DataReaderImpl(new ByteArrayInputStream(data));
            } finally {
                store.closeRecordStore();
            }
        } catch (RecordStoreException ex) {
            throw new IOException(ex.getMessage());
        }
    }
View Full Code Here


        return result;
    }

    public boolean existsData() throws IOException {
        try {
            final RecordStore store = RecordStore.openRecordStore("list", false);
            try {
                return true;
            } finally {
                store.closeRecordStore();
            }
        } catch (RecordStoreNotFoundException ex) {
            return false;
        } catch (RecordStoreException ex) {
            throw new IOException(ex.getMessage());
View Full Code Here

    public StoredFileInfo getFileInfo(String fileName) throws IOException {
        final StoredFileInfo result = new StoredFileInfo();

        try {
            final RecordStore store = RecordStore.openRecordStore(fileName, false);
            try {
                final byte[] data = store.getRecord(1);
                result.fileLength = data.length;
                result.fileCRC = CRC32.calculate(data);
            } finally {
                store.closeRecordStore();
            }
        } catch (RecordStoreNotFoundException ex) {
            result.fileLength = -1;
        } catch (RecordStoreException ex) {
            throw new IOException(ex.getMessage());
View Full Code Here

        return result;
    }

    public void saveFile(String fileName, byte[] data) throws IOException {
        try {
            final RecordStore store = RecordStore.openRecordStore(fileName, true);
            try {
                if (store.getNumRecords() == 0) {
                    store.addRecord(data, 0, data.length);
                } else {
                    store.setRecord(1, data, 0, data.length);
                }
            } finally {
                store.closeRecordStore();
            }
        } catch (RecordStoreException ex) {
            throw new IOException(ex.getMessage());
        }
    }
View Full Code Here

   *                                   fails
   */
  protected void initModel(ProgressMonitor rMonitor)
    throws UserNotificationException
  {
    RecordStore          aRS  = null;
    HierarchicalRecordStorage aHRS = null;

    if (aDataModel == null)
    {
      try
View Full Code Here

    { // just a try...
    }

    try
    {
      RecordStore aRS = RecordStore.openRecordStore(RECORDSTORE_NAME,
                              true);

      aHRS   = new HierarchicalRecordStorage(aRS);
      aModel = new MicroSafeModel(aHRS);
View Full Code Here

public boolean getIsItFirstTime() {
        return isItFirstTime;
    }

public void loadOptionDataBase() {
        RecordStore recordStore = null;
        DataInputStream inputStream = null;
        try {
      recordStore = RecordStore.openRecordStore("optionPrefer", false);
            byte[] bytes = recordStore.getRecord(1);
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            inputStream = new DataInputStream(bais);
           // isDSTOn=inputStream.readBoolean();
            fontSize=inputStream.readByte();
            volumeLevel=inputStream.readByte();
            screenTop=inputStream.readByte();
            hijriCorrection=inputStream.readByte();
         
            isFullScreen=inputStream.readBoolean();
            isMilitary=inputStream.readBoolean();
        } catch (Exception ex) {
          fontSize=0;//0 for 0 medium 16 large
          volumeLevel=50
          screenTop=0;
          hijriCorrection=0;
          isFullScreen=false;
          isMilitary=true;
          isItFirstTime=true;
          //System.out.println("calıstı");
        } finally {
            try {inputStream.close();} catch (Exception ex) {}
            try {recordStore.closeRecordStore();} catch (Exception ex) {}
        }
    }
View Full Code Here

            try {recordStore.closeRecordStore();} catch (Exception ex) {}
        }
    }
public void saveToDataBase ()
    {
        RecordStore recordStore;
        DataOutputStream outputStream;
        try {
            recordStore = RecordStore.openRecordStore("optionPrefer", true);
        } catch (RecordStoreException rsc) {
            return;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        outputStream = new DataOutputStream(baos);
        try {
       //     outputStream.writeBoolean(isDSTOn);
            outputStream.writeByte(fontSize);
            outputStream.writeByte(volumeLevel);
            outputStream.writeByte(screenTop);
            outputStream.writeByte(hijriCorrection);
            outputStream.writeBoolean(isFullScreen);
            outputStream.writeBoolean(isMilitary);
            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

      return  earlyWarnings;
    }

    
  public void saveWarnPreferInfo() {
                    RecordStore recordStore;
                    DataOutputStream outputStream;
                    try {
                        recordStore = RecordStore.openRecordStore("warningPrefer", true);
                    } catch (RecordStoreException rsc) {
                        return;
                    }
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    outputStream = new DataOutputStream(baos);
                    try {
                        outputStream.writeByte(fajrEWM);
                        outputStream.writeByte(sunRiseEWM);
                        outputStream.writeByte(zuhrEWM);
                        outputStream.writeByte(asrEWM);
                        outputStream.writeByte(magribEWM);
                        outputStream.writeByte(ishaEWM);
                        outputStream.writeByte(fajrWarn);
                        outputStream.writeByte(sunRiseWarn);
                        outputStream.writeByte(zuhrWarn);
                        outputStream.writeByte(asrWarn);
                        outputStream.writeByte(magribWarn);
                        outputStream.writeByte(ishaWarn);
                       
                        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 {recordStore.closeRecordStore();} catch (Exception ex) {}
    }
       }

public void loadWarnPreferInfo() {
             RecordStore recordStore = null;
             DataInputStream inputStream = null;
             try {
           recordStore = RecordStore.openRecordStore("warningPrefer", false);
                 byte[] bytes = recordStore.getRecord(1);
                 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                 inputStream = new DataInputStream(bais);

                 fajrEWM=inputStream.readByte();
                 sunRiseEWM=inputStream.readByte();
                 zuhrEWM=inputStream.readByte();
                 asrEWM=inputStream.readByte();
                 magribEWM=inputStream.readByte();
                 ishaEWM=inputStream.readByte();
                 fajrWarn=inputStream.readByte();
                 sunRiseWarn=inputStream.readByte();
                             zuhrWarn=inputStream.readByte();
                             asrWarn=inputStream.readByte();
                             magribWarn=inputStream.readByte();
                 ishaWarn=inputStream.readByte();
                          

             } catch (Exception ex) {
                             fajrEWM=0;
                             sunRiseEWM=45;
                             zuhrEWM=0;
                             asrEWM=0;
                             magribEWM=0;
                             ishaEWM=0;
                             fajrWarn=0;
                             sunRiseWarn=5;
                             zuhrWarn=5;
                             asrWarn=5;
                             magribWarn=5;
                 ishaWarn=5;
                             isItFirstTime=true;

             } finally {
                 try {inputStream.close();} catch (Exception ex) {}
                 try {recordStore.closeRecordStore();} catch (Exception ex) {}
             }
    }
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.