When storing simple data, I prefer to use JSON objects, since the code is simpler and more understandable for future maintainers than manipulating byte arrays. Because the objects are small, the penalty for using strings instead of byte arrays is small.
private static final String LATITUDE = "com.somepackage.name.LATITUDE"; private static final String LONGITUDE = "com.somepackage.name.LONGITUDE"; public boolean saveLocation(String key, Location location) { LOG.info("Saving location"); try { JSONObject locationJson = new JSONObject(); locationJson.put(LATITUDE, location.getLatitude()); locationJson.put(LONGITUDE, location.getLongitude());
source share