Search in sources :

Example 1 with RecordStoreNotOpenException

use of javax.microedition.rms.RecordStoreNotOpenException in project J2ME-Loader by nikita36078.

the class RecordStoreImpl method getSize.

@Override
public int getSize() throws RecordStoreNotOpenException {
    if (!open) {
        throw new RecordStoreNotOpenException();
    }
    // TODO include size overhead such as the data structures used to hold the state of the record store
    // Preload all records
    enumerateRecords(null, null, false);
    int result = 0;
    Enumeration keys = records.keys();
    while (keys.hasMoreElements()) {
        int key = ((Integer) keys.nextElement()).intValue();
        try {
            byte[] data = getRecord(key);
            if (data != null) {
                result += data.length;
            }
        } catch (RecordStoreException e) {
            e.printStackTrace();
        }
    }
    return result;
}
Also used : RecordStoreNotOpenException(javax.microedition.rms.RecordStoreNotOpenException) Enumeration(java.util.Enumeration) RecordEnumeration(javax.microedition.rms.RecordEnumeration) RecordStoreException(javax.microedition.rms.RecordStoreException)

Aggregations

Enumeration (java.util.Enumeration)1 RecordEnumeration (javax.microedition.rms.RecordEnumeration)1 RecordStoreException (javax.microedition.rms.RecordStoreException)1 RecordStoreNotOpenException (javax.microedition.rms.RecordStoreNotOpenException)1