package jk;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import fk.l;
import java.io.IOException;
import mk.c0;
import mk.t;
import nk.o;

/* loaded from: classes3.dex */
public final class e implements l {

    /* renamed from: a, reason: collision with root package name */
    private final SharedPreferences.Editor f25040a;

    /* renamed from: b, reason: collision with root package name */
    private final String f25041b;

    public e(Context context, String str, String str2) {
        if (str == null) {
            throw new IllegalArgumentException("keysetName cannot be null");
        }
        this.f25041b = str;
        Context applicationContext = context.getApplicationContext();
        if (str2 == null) {
            this.f25040a = PreferenceManager.getDefaultSharedPreferences(applicationContext).edit();
        } else {
            this.f25040a = applicationContext.getSharedPreferences(str2, 0).edit();
        }
    }

    @Override // fk.l
    public void a(t tVar) {
        if (!this.f25040a.putString(this.f25041b, o.b(tVar.c())).commit()) {
            throw new IOException("Failed to write to SharedPreferences");
        }
    }

    @Override // fk.l
    public void b(c0 c0Var) {
        if (!this.f25040a.putString(this.f25041b, o.b(c0Var.c())).commit()) {
            throw new IOException("Failed to write to SharedPreferences");
        }
    }
}
