How to store json object to shared preferences?

前端 未结 8 1342
栀梦
栀梦 2020-12-21 22:53

I am creating an application,In my app I am getting response and displaing it in custom alert dialog, Till here it works fine, Now what I am trying to do is if user selects

8条回答
  •  青春惊慌失措
    2020-12-21 23:22

    Basically you could check if the value of preferences is stored or not.

    you could do this onCreate() method:
    Check if preference value exists
    if yes:
    then no need to make AsyncTask call
    and if no:
    then make the AsyncTask call

    Code:

    String statename = preferences.getString("STATE_NAME,"");
     if(statename!=""){
       //Then directly go inside main activity
    
     }
     else{
    //Make AsyncTask Call
    
     }
    

提交回复
热议问题