package com.carmaintenance;

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

public class TokenStore {
    private static final String PREFS_NAME = "auth_prefs";
    private static final String KEY_TOKEN = "token";

    private final SharedPreferences preferences;

    public TokenStore(Context context) {
        this.preferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    }

    public void saveToken(String token) {
        preferences.edit().putString(KEY_TOKEN, token).apply();
    }

    public String getToken() {
        return preferences.getString(KEY_TOKEN, null);
    }

    public void clear() {
        preferences.edit().remove(KEY_TOKEN).apply();
    }
}
