Back to project page BehatReporter.
The source code is released under:
Copyright (C) 2013 Fabian Kiss <headrevision@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...
If you think the Android project BehatReporter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package headrevision.BehatReporter.store; /*w w w . ja v a 2s .c om*/ import headrevision.BehatReporter.json.Reader; import headrevision.BehatReporter.json.ReaderException; import android.app.Activity; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import com.fasterxml.jackson.databind.JsonNode; public class ReportJson { private static ReportJson instance; private Activity activity; private SharedPreferences preferences; private ReportJson(Activity activity) { this.activity = activity; preferences = activity.getPreferences(Activity.MODE_PRIVATE); } public static ReportJson getInstance(Activity activity) { if (instance == null || instance.activity != activity) { instance = new ReportJson(activity); } return instance; } public JsonNode retrieve() { String reportJson = preferences.getString("report_json", ""); Reader jsonReader = new Reader(reportJson); try { return jsonReader.read(); } catch (ReaderException e) { return null; } } public void save(JsonNode reportJson) { Editor editor = preferences.edit(); editor.putString("report_json", reportJson.toString()); editor.commit(); } }