Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabianterhorst/floppy
Fast object key value storage for Java with much support for Android
https://github.com/fabianterhorst/floppy
android android-database-api java storage
Last synced: about 2 months ago
JSON representation
Fast object key value storage for Java with much support for Android
- Host: GitHub
- URL: https://github.com/fabianterhorst/floppy
- Owner: FabianTerhorst
- License: apache-2.0
- Created: 2016-09-18T18:05:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-16T15:58:14.000Z (over 7 years ago)
- Last Synced: 2024-10-31T14:46:12.301Z (2 months ago)
- Topics: android, android-database-api, java, storage
- Language: Java
- Homepage:
- Size: 191 KB
- Stars: 82
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Floppy
Fast key value storage for Java with much support for Android```java
Floppy.init(getFilesDir().toString());
//Without cache
Disk disk = Floppy.disk();
//With cache
Disk disk = Floppy.memoryDisk();
//Without cache, with custom name
Disk disk = Floppy.disk("custom disk");
//With cache, with custom name
Disk disk = Floppy.memoryDisk("custom memory disk");
disk.write("key", object);
disk.read("key");
disk.delete("key");
disk.deleteAll();
disk.setOnWriteListener("testKey", new OnWriteListener() {
@Override
public void onWrite(String value) {
//value = test
}
});
disk.write("testKey", "test");
```
## Array support
The array support is internally a memory disk
```java
//Without custom name
ArrayDisk disk = Floppy.arrayDisk();
//With custom name
ArrayDisk disk = Floppy.arrayDisk("custom array disk");
disk.addOnChangeListener("items", new OnChangeListener() {
@Override
public void onChange(Item item, int index) {
//item changed
}
});
Item item = new Item();
disk.addItem("items", item);
int index = 5;
disk.removeItem("items", index);
//To find the right item in the array (is used in change and remove item)
disk.addOnEqualListener("items", new OnEqualListener() {
@Override
public boolean isEqual(Item currentItem, Item newItem) {
return currentItem.getId() == newItem.getId();
}
});
disk.removeItem("items", item);
//This doesn´t need addOnEqualListener
disk.changeItem("items", new OnFindListener() {
@Override
public boolean isObject(Item item) {
return item.getId() == 4;
}
}, new OnReadListener() {
@Override
public Object onRead(Item item) {
item.setName("item4´s new Name")
return item;
}
});
```gradle
```groovy
compile 'io.fabianterhorst:Floppy:0.2.6'
```maven
```xmlio.fabianterhorst
Floppy
0.2.0
pom```