BasicRms.java
/*
* Copyright © 2012 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners.
* See LICENSE.TXT for license information.
*/
package com.nokia.example;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
/**
* Basic RMS usage example. Record store is kept open between gets.
*/
public class BasicRms implements RmsConnection {
private String rmsName = "BasicRms";
RecordStore rms;
public void open() {
try {
rms = RecordStore.openRecordStore(rmsName, true);
} catch (RecordStoreException rse) {
rse.printStackTrace();
}
}
public byte[] get() {
byte[] data = null;
try {
data = rms.getRecord(1);
} catch (RecordStoreException rse) {
rse.printStackTrace();
}
return data;
}
public void set(byte[] data) {
try {
rms.addRecord(data, 0, data.length);
} catch (RecordStoreException rse) {
rse.printStackTrace();
}
}
public void close() {
try {
rms.closeRecordStore();
} catch (RecordStoreException rse) {
//rse.printStackTrace();
}
}
}