package com.google.android.gms.internal.ads;

import android.content.Context;
import android.content.SharedPreferences;
import java.io.IOException;

/* JADX INFO: loaded from: classes2.dex */
public final class pj1 {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static pj1 f15444c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final String f15445a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final SharedPreferences f15446b;

    public pj1(Context context) {
        this.f15445a = context.getPackageName();
        this.f15446b = context.getSharedPreferences("paid_storage_sp", 0);
    }

    public final void a(Object obj, String str) throws IOException {
        boolean zCommit;
        boolean z10 = obj instanceof String;
        String str2 = this.f15445a;
        SharedPreferences sharedPreferences = this.f15446b;
        if (z10) {
            zCommit = sharedPreferences.edit().putString(str, (String) obj).commit();
        } else if (obj instanceof Long) {
            zCommit = sharedPreferences.edit().putLong(str, ((Long) obj).longValue()).commit();
        } else if (obj instanceof Boolean) {
            zCommit = sharedPreferences.edit().putBoolean(str, ((Boolean) obj).booleanValue()).commit();
        } else {
            if (!(obj instanceof Integer)) {
                new StringBuilder(String.valueOf(obj.getClass()).length() + 33 + String.valueOf(str2).length());
                throw new IOException(com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.h(new StringBuilder(str.length() + 25 + String.valueOf(str2).length()), "Failed to store ", str, " for app ", str2));
            }
            zCommit = sharedPreferences.edit().putInt(str, ((Integer) obj).intValue()).commit();
        }
        if (zCommit) {
            return;
        }
        throw new IOException(com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.h(new StringBuilder(str.length() + 25 + String.valueOf(str2).length()), "Failed to store ", str, " for app ", str2));
    }

    public final void b(String str) throws IOException {
        if (this.f15446b.edit().remove(str).commit()) {
            return;
        }
        int length = str.length();
        String str2 = this.f15445a;
        throw new IOException(com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.h(new StringBuilder(length + 26 + String.valueOf(str2).length()), "Failed to remove ", str, " for app ", str2));
    }
}
