Skip to content

Commit 0d11da9

Browse files
committed
Review feedback
1 parent 9c277a1 commit 0d11da9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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.
33
Previous method could be off by a few MBs on these devices, potentially
44
delaying garbage collection.
55

firebase-firestore/src/main/java/com/google/firebase/firestore/local/SQLitePersistence.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ long getByteSize() {
205205
* @see https://www.sqlite.org/pragma.html#pragma_page_size
206206
*/
207207
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+
}
209215
}
210216

211217
/**
@@ -215,15 +221,7 @@ private long getPageSize() {
215221
* @see https://www.sqlite.org/pragma.html#pragma_page_count.
216222
*/
217223
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);
227225
try {
228226
cursor.moveToFirst();
229227
return cursor.getLong(/*column=*/ 0);

0 commit comments

Comments
 (0)