package tr.xip.wanikani.managers;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Environment;
import android.preference.PreferenceManager;

/**
 * Created by xihsa_000 on 3/11/14.
 */
public class PrefManager {
    private static SharedPreferences prefs;
    private static SharedPreferences.Editor prefeditor;
    private static Context context;

    public PrefManager(Context mContext) {
        context = mContext;
        prefs = context.getSharedPreferences("prefs", 0);
        prefeditor = prefs.edit();
    }

    public String getApiKey() {
        return prefs.getString("api_key", "0");
    }

    public boolean isFirstLaunch() {
        return prefs.getBoolean("first_launch", true);
    }

    public void setFirstLaunch(boolean value) {
        prefeditor.putBoolean("first_launch", value).commit();
    }

    public void setApiKey(String key) {
        prefeditor.putString("api_key", key).commit();
    }

    public boolean isProfileFirstTime() {
        return prefs.getBoolean("first_time_profile", true);
    }

    public void setProfileFirstTime(boolean value) {
        prefeditor.putBoolean("first_time_profile", value).commit();
    }

    public void logout() {
        prefeditor.clear().commit();
    }

}

@@ -334,21 +334,134 @@
 nces
-.Editor prefe
+ offlineData;%0A    private static SharedPreferences.Editor prefeditor;%0A    private static SharedPreferences.Editor offlineDataE
 dito
@@ -641,26 +641,145 @@
     
-prefeditor = prefs
+offlineData = context.getSharedPreferences(%22offline_data%22, 0);%0A        prefeditor = prefs.edit();%0A        offlineDataEditor = offlineData
 .edi
@@ -1495,21 +1495,65 @@
 ).commit();%0A
+        offlineDataEditor.clear().commit();%0A
     %7D%0A%0A%7D%0A

Clear offline data on logout