Fixed application crash while running application on the emulators.

This commit is contained in:
MohitMali 2023-09-06 18:53:01 +05:30 committed by MohitMaliFtechiz
parent 429502af19
commit 3d7a4af7d3

View File

@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.core.dao package org.kiwix.kiwixmobile.core.dao
import android.os.Build
import io.reactivex.BackpressureStrategy import io.reactivex.BackpressureStrategy
import io.reactivex.BackpressureStrategy.LATEST import io.reactivex.BackpressureStrategy.LATEST
import io.reactivex.Flowable import io.reactivex.Flowable
@ -46,9 +47,16 @@ class LibkiwixBookmarks @Inject constructor(
} }
private val bookmarksFolderPath: String by lazy { private val bookmarksFolderPath: String by lazy {
sharedPreferenceUtil.getPublicDirectoryPath( if (Build.DEVICE.contains("generic")) {
sharedPreferenceUtil.defaultStorage() // Workaround for emulators: Emulators have limited memory and
) + "/kiwix/Bookmarks/" // restrictions on creating folders, so we will use the default
// path for saving the bookmark file.
sharedPreferenceUtil.context.filesDir.path
} else {
sharedPreferenceUtil.getPublicDirectoryPath(
sharedPreferenceUtil.defaultStorage()
) + "/kiwix/Bookmarks/"
}
} }
private val bookmarkFile: File by lazy { private val bookmarkFile: File by lazy {