File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed
src/main/java/com/google/firebase/firestore/local Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
- - [ fixed] Fixed calculation of SQLite database size on Android 9 (P) devices.
2
+ - [ fixed] Fixed calculation of SQLite database size on Android 9 Pie devices.
3
3
Previous method could be off by a few MBs on these devices, potentially
4
4
delaying garbage collection.
5
5
Original file line number Diff line number Diff line change @@ -205,7 +205,13 @@ long getByteSize() {
205
205
* @see https://www.sqlite.org/pragma.html#pragma_page_size
206
206
*/
207
207
private long getPageSize () {
208
- return pragma ("page_size" );
208
+ Cursor cursor = db .rawQuery ("PRAGMA page_size" , null );
209
+ try {
210
+ cursor .moveToFirst ();
211
+ return cursor .getLong (/*column=*/ 0 );
212
+ } finally {
213
+ cursor .close ();
214
+ }
209
215
}
210
216
211
217
/**
@@ -215,15 +221,7 @@ private long getPageSize() {
215
221
* @see https://www.sqlite.org/pragma.html#pragma_page_count.
216
222
*/
217
223
private long getPageCount () {
218
- return pragma ("page_count" );
219
- }
220
-
221
- /**
222
- * @param pragmaName Must be a valid 'pragma-name' and must refer to a long value.
223
- * @see https://www.sqlite.org/pragma.html
224
- */
225
- private long pragma (String pragmaName ) {
226
- Cursor cursor = db .rawQuery ("PRAGMA " + pragmaName , null );
224
+ Cursor cursor = db .rawQuery ("PRAGMA page_count" , null );
227
225
try {
228
226
cursor .moveToFirst ();
229
227
return cursor .getLong (/*column=*/ 0 );
You can’t perform that action at this time.
0 commit comments