mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-22 02:07:43 +07:00
Resolved #7177 - Android custom location save
This commit is contained in:
parent
dd9f946de9
commit
04cb4bd2a9
@ -23,15 +23,17 @@ class CustomFileLocationHelperAndroid(private val activity: Activity) : CustomFi
|
||||
// When we loaded, we returned a "content://" URI as file location.
|
||||
val uri = Uri.parse(suggestedLocation)
|
||||
val fileName = if (uri.scheme == "content") {
|
||||
val cursor = activity.contentResolver.query(uri, null, null, null, null)
|
||||
cursor.use {
|
||||
// we should have a direct URI to a file, so first is enough
|
||||
if (it?.moveToFirst() == true) {
|
||||
it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
|
||||
} else {
|
||||
""
|
||||
try {
|
||||
val cursor = activity.contentResolver.query(uri, null, null, null, null)
|
||||
cursor.use {
|
||||
// we should have a direct URI to a file, so first is enough
|
||||
if (it?.moveToFirst() == true) {
|
||||
it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
|
||||
} else ""
|
||||
}
|
||||
}
|
||||
catch(ex:Exception) {}
|
||||
suggestedLocation.split("2F").last() // I have no idea why but the content path ends with this before the filename
|
||||
} else {
|
||||
// if we didn't load, this is some file name entered by the user
|
||||
suggestedLocation
|
||||
|
Loading…
Reference in New Issue
Block a user