use of javax.microedition.rms.RecordStoreNotFoundException in project J2ME-Loader by nikita36078.
the class AndroidRecordStoreManager method openRecordStore.
@Override
public RecordStore openRecordStore(String recordStoreName, boolean createIfNecessary) throws RecordStoreException {
initializeIfNecessary();
RecordStoreImpl recordStoreImpl;
try {
DataInputStream dis = new DataInputStream(ContextHolder.openFileInput(getHeaderFileName(recordStoreName)));
recordStoreImpl = new RecordStoreImpl(this);
recordStoreImpl.readHeader(dis);
recordStoreImpl.setOpen(true);
dis.close();
} catch (FileNotFoundException e) {
if (!createIfNecessary) {
throw new RecordStoreNotFoundException(recordStoreName);
}
recordStoreImpl = new RecordStoreImpl(this, recordStoreName);
recordStoreImpl.setOpen(true);
saveToDisk(recordStoreImpl, -1);
} catch (IOException e) {
throw new RecordStoreException();
}
recordStores.put(recordStoreName, recordStoreImpl);
return recordStoreImpl;
}
use of javax.microedition.rms.RecordStoreNotFoundException in project J2ME-Loader by nikita36078.
the class AndroidRecordStoreManager method deleteRecordStore.
@Override
public void deleteRecordStore(final String recordStoreName) throws RecordStoreNotFoundException, RecordStoreException {
initializeIfNecessary();
Object value = recordStores.get(recordStoreName);
if (value == null) {
throw new RecordStoreNotFoundException(recordStoreName);
}
if (value instanceof RecordStoreImpl && ((RecordStoreImpl) value).isOpen()) {
throw new RecordStoreException();
}
RecordStoreImpl recordStoreImpl;
try {
DataInputStream dis = new DataInputStream(ContextHolder.openFileInput(getHeaderFileName(recordStoreName)));
recordStoreImpl = new RecordStoreImpl(this);
recordStoreImpl.readHeader(dis);
dis.close();
} catch (IOException e) {
Log.e(TAG, "RecordStore.deleteRecordStore: ERROR reading " + getHeaderFileName(recordStoreName), e);
throw new RecordStoreException();
}
recordStoreImpl.setOpen(true);
RecordEnumeration re = recordStoreImpl.enumerateRecords(null, null, false);
while (re.hasNextElement()) {
ContextHolder.deleteFile(getRecordFileName(recordStoreName, re.nextRecordId()));
}
recordStoreImpl.setOpen(false);
ContextHolder.deleteFile(getHeaderFileName(recordStoreName));
recordStores.remove(recordStoreName);
}
Aggregations