diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/LibkiwixBookmarks.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/LibkiwixBookmarks.kt
index 4da1539b8..f9cbf48c2 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/LibkiwixBookmarks.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/LibkiwixBookmarks.kt
@@ -19,6 +19,7 @@
package org.kiwix.kiwixmobile.core.dao
import android.os.Build
+import android.os.Environment
import android.util.Base64
import io.reactivex.BackpressureStrategy
import io.reactivex.BackpressureStrategy.LATEST
@@ -28,9 +29,7 @@ import io.reactivex.subjects.BehaviorSubject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
-import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.R
-import org.kiwix.kiwixmobile.core.extensions.deleteFile
import org.kiwix.kiwixmobile.core.extensions.isFileExist
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.page.adapter.Page
@@ -287,7 +286,7 @@ class LibkiwixBookmarks @Inject constructor(
sharedPreferenceUtil.context.toast(
sharedPreferenceUtil.context.getString(
R.string.export_bookmark_saved,
- "${bookmarkDestinationFile.parent}/"
+ bookmarkDestinationFile.name
)
)
} catch (ignore: Exception) {
@@ -297,12 +296,21 @@ class LibkiwixBookmarks @Inject constructor(
}
private fun exportedFile(fileName: String): File {
- val rootFolder = CoreApp.instance.externalMediaDirs[0]
+ val rootFolder = File(
+ "${Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)}" +
+ "/org.kiwix"
+ )
if (!rootFolder.isFileExist()) rootFolder.mkdir()
- val file = File(rootFolder, fileName)
- if (file.isFileExist()) file.deleteFile()
- file.createNewFile()
- return file
+ return sequence {
+ yield(File(rootFolder, fileName))
+ yieldAll(
+ generateSequence(1) { it + 1 }.map {
+ File(
+ rootFolder, fileName.replace(".", "_$it.")
+ )
+ }
+ )
+ }.first { !it.isFileExist() }
}
companion object {
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 35fe9c846..b6ad95244 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -79,7 +79,7 @@
Permissions
Export Bookmarks
Export all saved bookmarks
- Bookmarks are exported in %s folder
+ Bookmarks are exported in %s file
All History Cleared
Clear bookmarks
Clear All History?
@@ -295,7 +295,7 @@
Delete All Bookmarks?
Delete Selected Bookmarks?
Export All Bookmarks?
- Exporting will generate bookmark.xml file in the Android/media/org.kiwix…/ folder. To import bookmarks, simply copy this file into the Android/data/org.kiwix…/files/Bookmarks/ folder.
+ Exporting will generate bookmark.xml file in the Download/org.kiwix…/ folder.
On
Off
Auto