@Override public void clear() { db.getAllNames().forEach(name -> { Object struct = db.get(name); if (struct instanceof Collection) ((Collection) struct).clear(); else if (struct instanceof Map) ((Map) struct).clear(); }); commit(); }
@Override public String info(String name) { Object struct = db.get(name); if (isNull(struct)) throw new IllegalStateException(format("DB structure with name [%s] does not exist", name)); if (struct instanceof Set) return format("%s - Set - %d", name, ((Set) struct).size()); else if (struct instanceof List) return format("%s - List - %d", name, ((List) struct).size()); else if (struct instanceof Map) return format("%s - Map - %d", name, ((Map) struct).size()); else return format("%s - %s", name, struct.getClass().getSimpleName()); }
try { DB snappydb = DBFactory.open(context); //create or open an existing databse using the default name snappydb.put("name", "Jack Reacher"); snappydb.putInt("age", 42); snappydb.putBoolean("single", true); snappydb.put("books", new String[]{"One Shot", "Tripwire", "61 Hours"}); String name = snappydb.get("name"); int age = snappydb.getInt("age"); boolean single = snappydb.getBoolean("single"); String[] books = snappydb.getArray("books", String.class);// get array of string snappydb.close(); } catch (SnappydbException e) { }
/** * ??? * * @param name ??? * @param <E> ??? * * @return ??? */ @VisibleForTesting public <E> E get(String name) { return db.get(name); }
public <E> E get(final String name) { this.assertNotClosed(); return this.tx.get(name); }
try { DB snappydb = DBFactory.open(getActivity()); //create or open an existing databse using the default name //Saving List of LatLng ArrayList<LatLng> listOfLatLng = new ArrayList<LatLng>(); snappydb.put("LATLNG", listOfLatLng); //Retrieving List of LatLngs ArrayList<LatLng> listOfLatLngNew = snappydb.get("LATLNG",ArrayList.class); snappydb.close(); } catch (SnappydbException e) { e.printStackTrace(); }