package com.mbridge.msdk.foundation.db; import android.content.ContentValues; import android.database.Cursor; import com.mbridge.msdk.MBridgeConstans; import java.util.ArrayList; import java.util.List; /* loaded from: classes4.dex */ public class m extends a { private static m a; private m(f fVar) { super(fVar); } public static m a(f fVar) { if (a == null) { synchronized (m.class) { try { if (a == null) { a = new m(fVar); } } finally { } } } return a; } public final synchronized void a(String str) { if (getWritableDatabase() != null) { getWritableDatabase().delete(MBridgeConstans.PROPERTIES_UNIT_ID, "unitId = ?", new String[]{str + ""}); } } public final synchronized void a(String str, String str2, int i) { if (getWritableDatabase() == null) { return; } ContentValues contentValues = new ContentValues(); contentValues.put("placement_id", str); contentValues.put("unitId", str2); contentValues.put("ad_type", Integer.valueOf(i)); getWritableDatabase().insert(MBridgeConstans.PROPERTIES_UNIT_ID, null, contentValues); } public final synchronized List a(int i) { ArrayList arrayList; ArrayList arrayList2; Cursor cursor = null; arrayList2 = null; arrayList2 = null; cursor = null; try { try { Cursor rawQuery = getReadableDatabase().rawQuery("select * from unit_id WHERE ad_type = ?", new String[]{String.valueOf(i)}); if (rawQuery != null) { try { try { if (rawQuery.getCount() > 0) { arrayList = new ArrayList(rawQuery.getCount()); while (rawQuery.moveToNext()) { try { arrayList.add(new com.mbridge.msdk.foundation.entity.i(rawQuery.getString(rawQuery.getColumnIndex("placement_id")), rawQuery.getString(rawQuery.getColumnIndex("unitId")), i)); } catch (Exception e) { e = e; cursor = rawQuery; e.printStackTrace(); if (cursor != null) { try { cursor.close(); } catch (Exception unused) { } } arrayList2 = arrayList; return arrayList2; } } arrayList2 = arrayList; } } catch (Throwable th) { th = th; cursor = rawQuery; if (cursor != null) { try { cursor.close(); } catch (Exception unused2) { } } throw th; } } catch (Exception e2) { e = e2; arrayList = null; } } if (rawQuery != null) { try { rawQuery.close(); } catch (Exception unused3) { } } } catch (Exception e3) { e = e3; arrayList = null; } } catch (Throwable th2) { th = th2; } return arrayList2; } }