Я хочу вернуть ответ о модернизации?
Я пытался, но не смог найти ответ? Я также попытался с SharedPreferences, но это было полезно для первого шага. Когда я позвонил в класс, он работал впервые? Это мой код.
public class NoteClass {
String MetaKey;
public String MetaValue;
SharedPreferences shared_guidace;
public static final String mypref_guidace = "mypref_guidace";
public static String GuidanceText = "GuidanceTextKey";
public void getGuidanceText (String metaKey , final Context Getcontext)
{
GetConfigObject getConfigObject = new GetConfigObject();
getConfigObject.setMetaKey(metaKey);
GetConfigRequest getConfigRequest = RetrofitHelper.getInstance().getRetrofit().create(GetConfigRequest.class);
getConfigRequest.getConfigFunc(getConfigObject).enqueue(new Callback<GetConfigModel>() {
@Override
public void onResponse(Call<GetConfigModel> call, Response<GetConfigModel> response) {
if(response.isSuccessful())
{
shared_guidace = Getcontext.getSharedPreferences(mypref_guidace, Context.MODE_PRIVATE);
if(response.body().getGetConfigResult().getStatus())
{
MetaValue = response.body().getGetConfigResult().getData().getMetaValue();
shared_guidace = Getcontext.getSharedPreferences(mypref_guidace, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = shared_guidace.edit();
editor.putString(GuidanceText , MetaValue);
editor.commit();
}
else
{
Toast.makeText( Getcontext , response.body().getGetConfigResult().getMessage() , Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onFailure(Call<GetConfigModel> call, Throwable t) {
Toast.makeText( Getcontext ,"err." , Toast.LENGTH_LONG ).show();
}
});
}
public String Guidance(final Context Getcontext)
{
shared_guidace = Getcontext.getSharedPreferences(mypref_guidace, Context.MODE_PRIVATE);
String Value = shared_guidace.getString( GuidanceText , "");
return Value;
}}
// i call it
GuidanceNoteClass guidanceNoteClass2 = new GuidanceNoteClass();
guidanceNoteClass2.getGuidanceText("view" , getContext() );
String view = guidanceNoteClass2.Guidance( getContext() );
GuidanceNoteClass guidanceNoteClass3 = new GuidanceNoteClass();
guidanceNoteClass3.getGuidanceText("edit" , getContext() );
String edit = guidanceNoteClass3.Guidance( getContext() );
Я дважды позвонил в класс, но в результате второй класс такой же, как и первый.