我试图理解基于java的android应用程序中数据存储的实现。医院里有个医生https://developer.android.com/topic/libraries/architecture/datastore#java 但没有任何解释。有没有人可以写一个例子来说明如何将这个代码用于两个不同的键,或者如何重写java共享引用代码来读写数据存储代码?
//write
SharedPreferences prefs;
prefs = Shared.context.getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("myBoolean", myBooleand);
editor.putInt("myInt", myInt);
editor.apply();
//read
SharedPreferences prefs = Shared.context.getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
myBoolean = prefs.getBoolean("myBoolean", true);
myInt = prefs.getInt("myInt",100 );
暂无答案!
目前还没有任何答案,快来回答吧!