/*
 *
 *  * Copyright (C) 2017 Safaricom, Ltd.
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  * http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 */

package com.myduka.app.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created  on 7/4/2017.
 */

public class SharedPrefsUtil {
    SharedPreferences pref;
    SharedPreferences.Editor editor;
    Context context;
    int PRIVATE_MODE = 0;

    private static final String SHARED_PREFER_FILE_NAME = "keys";

    /**
     * Retrieve data from preference:
     */

    public SharedPrefsUtil(Context context) {
        this.context = context;
        pref = context.getSharedPreferences(SHARED_PREFER_FILE_NAME, PRIVATE_MODE);
        editor = pref.edit();
    }

    /**
     * Setting values in Preference:
     */


    public void createKey(String key_name) {
        editor.putString("key_name", key_name);
        editor.commit();
    }

    public String getTableName(){
        String table_name = pref.getString("key_name", null);
        return table_name;
    }
}

@@ -808,24 +808,32 @@
 sUtil %7B%0A    
+private 
 SharedPrefer
@@ -848,16 +848,24 @@
 ef;%0A    
+private 
 SharedPr
@@ -892,55 +892,8 @@
 tor;
-%0A    Context context;%0A    int PRIVATE_MODE = 0;
 %0A%0A  
@@ -1070,30 +1070,28 @@
     
-this.context = context
+int PRIVATE_MODE = 0
 ;%0A  
@@ -1210,64 +1210,33 @@
     
-%7D%0A%0A
     
-/**%0A     * Setting values in Preference:%0A 
+editor.apply();%0A
     
-*/%0A
+%7D
 %0A%0A  
@@ -1253,35 +1253,56 @@
 oid 
-createKey(String key_name) 
+saveFirebaseRegistrationID(String firebaseRegId)
 %7B%0A  
@@ -1329,27 +1329,29 @@
 ng(%22
-key_name%22, key_name
+regId%22, firebaseRegId
 );%0A 
@@ -1406,108 +1406,76 @@
  get
-TableName()%7B%0A        String table_name = pref.getString(%22key_name%22, null);%0A        return table_name
+irebaseRegistrationID()%7B%0A       return pref.getString(%22regId%22, null)
 ;%0A  

add methods to set and get firebase registration id