package com.ydl.ydlcommon.utils;

import android.app.Activity;
import android.content.SharedPreferences;
import com.ydl.ydlcommon.base.BaseApp;


public class SharedPreferencesEditor {


	public static final String TEMP_TEST = "temp_test";//临时SP

	/********************************************自定义文件存储***********************************************/

	public static void putFileString(String fileName,String key,String value) {
		SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
				fileName, Activity.MODE_PRIVATE);
		SharedPreferences.Editor editor = mySharedPreferences.edit();
		editor.putString(key, value);
		editor.commit();
	}

	public static String getFileString(String fileName,String key) {
		SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
				fileName, Activity.MODE_PRIVATE);
		return mySharedPreferences.getString(key, "");
	}

	/***********************************************临时保存************************************************/
	public static void putString(String key, String value) {
		SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
				TEMP_TEST, Activity.MODE_PRIVATE);
		SharedPreferences.Editor editor = mySharedPreferences.edit();
		editor.putString(key, value);
		editor.commit();
	}

	public static String getString(String key){
		SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
				TEMP_TEST, Activity.MODE_PRIVATE);
		return mySharedPreferences.getString(key, "");
	}

	public static final void clear(){

		SharedPreferences mySharedPreferencestemp = BaseApp.Companion.getApp().getSharedPreferences(
				TEMP_TEST, Activity.MODE_PRIVATE);
		SharedPreferences.Editor editort = mySharedPreferencestemp.edit();
		editort.clear();
		editort.commit();
	}
}
