enable large collections through larger cursor window

This commit is contained in:
malteish authored and Anthony La committed 2025-09-12 11:43:08 -07:00
1 parent b67734b8e1
commit afa520a68a
1 file changed
+18
@@ -16,6 +16,24 @@ import java.lang.reflect.Field
class App: Application() {
override fun onCreate() {
super.onCreate()
// Increase CursorWindow size to handle large datasets
// Default is usually 2MB, increasing to 10MB
try {
val field: Field = CursorWindow::class.java.getDeclaredField("sCursorWindowSize")
field.isAccessible = true
field.set(null, 10 * 1024 * 1024) // 10MB
} catch (e: Exception) {
// Fallback for newer Android versions where field might be different
try {
val field: Field = CursorWindow::class.java.getDeclaredField("CURSOR_WINDOW_SIZE")
field.isAccessible = true
field.set(null, 10 * 1024 * 1024) // 10MB
} catch (e2: Exception) {
e2.printStackTrace()
}
}
val channel = NotificationChannel("wallpaper_service_channel", "Paperize", NotificationManager.IMPORTANCE_LOW)
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)