我正在设计一个简单的应用程序,它将计算用户点击 imageView 的次数。我的问题是保存和读取此文件的最佳方式是什么。有什么建议么?我在考虑使用 Parse.com 的本地数据库。我试过了,但我无法让它按照我想要的方式工作。我还是个初学者,所以请不要那么花哨的建议。
最佳答案
尝试将数据保存在 SharedPreference 中。 SharedPreference 的工作方式类似于设备上应用程序的数据库,它将被存储直到任何人从设备上卸载应用程序。
创建 sharedPrefernce-
SharedPreferences prefs = this.getSharedPreferences(
"com.example.app", Context.MODE_PRIVATE);
存储数据-
prefs.edit().putInt("key", int_value).apply();
检索数据-
// use a default value
int l = prefs.getLong("key", default_value);
关于android - 如何保存用户点击 View 的次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30810872/