| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.database.sqlite; |
| 18 |
|
| 19 |
import android.compat.annotation.UnsupportedAppUsage; |
| 20 |
import android.os.Build; |
| 21 |
import android.os.ParcelFileDescriptor; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public final class SQLiteStatement extends SQLiteProgram { |
| 32 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 33 |
SQLiteStatement(SQLiteDatabase db, String sql, Object[] bindArgs) { |
| 34 |
super(db, sql, bindArgs, null); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public void execute() { |
| 45 |
acquireReference(); |
| 46 |
try { |
| 47 |
getSession().execute(getSql(), getBindArgs(), getConnectionFlags(), null); |
| 48 |
} catch (SQLiteDatabaseCorruptException ex) { |
| 49 |
onCorruption(); |
| 50 |
throw ex; |
| 51 |
} finally { |
| 52 |
releaseReference(); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public int executeUpdateDelete() { |
| 65 |
acquireReference(); |
| 66 |
try { |
| 67 |
return getSession().executeForChangedRowCount( |
| 68 |
getSql(), getBindArgs(), getConnectionFlags(), null); |
| 69 |
} catch (SQLiteDatabaseCorruptException ex) { |
| 70 |
onCorruption(); |
| 71 |
throw ex; |
| 72 |
} finally { |
| 73 |
releaseReference(); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
public long executeInsert() { |
| 87 |
acquireReference(); |
| 88 |
try { |
| 89 |
return getSession().executeForLastInsertedRowId( |
| 90 |
getSql(), getBindArgs(), getConnectionFlags(), null); |
| 91 |
} catch (SQLiteDatabaseCorruptException ex) { |
| 92 |
onCorruption(); |
| 93 |
throw ex; |
| 94 |
} finally { |
| 95 |
releaseReference(); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
public long simpleQueryForLong() { |
| 108 |
acquireReference(); |
| 109 |
try { |
| 110 |
return getSession().executeForLong( |
| 111 |
getSql(), getBindArgs(), getConnectionFlags(), null); |
| 112 |
} catch (SQLiteDatabaseCorruptException ex) { |
| 113 |
onCorruption(); |
| 114 |
throw ex; |
| 115 |
} finally { |
| 116 |
releaseReference(); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
public String simpleQueryForString() { |
| 129 |
acquireReference(); |
| 130 |
try { |
| 131 |
return getSession().executeForString( |
| 132 |
getSql(), getBindArgs(), getConnectionFlags(), null); |
| 133 |
} catch (SQLiteDatabaseCorruptException ex) { |
| 134 |
onCorruption(); |
| 135 |
throw ex; |
| 136 |
} finally { |
| 137 |
releaseReference(); |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
public ParcelFileDescriptor simpleQueryForBlobFileDescriptor() { |
| 150 |
acquireReference(); |
| 151 |
try { |
| 152 |
return getSession().executeForBlobFileDescriptor( |
| 153 |
getSql(), getBindArgs(), getConnectionFlags(), null); |
| 154 |
} catch (SQLiteDatabaseCorruptException ex) { |
| 155 |
onCorruption(); |
| 156 |
throw ex; |
| 157 |
} finally { |
| 158 |
releaseReference(); |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
@Override |
| 163 |
public String toString() { |
| 164 |
return "SQLiteProgram: " + getSql(); |
| 165 |
} |
| 166 |
} |