QStandardPaths::GenericDataLocation across different Qt versions (changed between 5.12 and 5.15)
-
Hi there,
I've developed an Android application using Qt 5.12 which allowed me to store files under
QStandardPaths::GenericDataLocation
that used to return a path like/storage/emulated/0/Android/data/<package_name>/files
.I had to update my Qt version to 5.15 due to other factors but the same call to
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
returned just/storage/emulated/0
without any reference to the current package's actual folder.Is this intended behavior for the 5.15 version or am I missing something?
-
Hi, and welcome!
@Lucone said in QStandardPaths::GenericDataLocation across different Qt versions (changed between 5.12 and 5.15):
Hi there,
I've developed an Android application using Qt 5.12 which allowed me to store files under
QStandardPaths::GenericDataLocation
that used to return a path like/storage/emulated/0/Android/data/<package_name>/files
.I had to update my Qt version to 5.15 due to other factors but the same call to
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
returned just/storage/emulated/0
without any reference to the current package's actual folder.Is this intended behavior for the 5.15 version or am I missing something?
https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum says that on Android,
GenericDataLocation
maps to <USER>DataLocation
maps to <APPROOT>/files
At the same time, the documentation contains a warning that "The paths above should not be relied upon, as they may change according to OS configuration, locale, or they may change in future Qt versions."
-
@Lucone said in QStandardPaths::GenericDataLocation across different Qt versions (changed between 5.12 and 5.15):
Is this intended behavior for the 5.15 version or am I missing something?
Yes, sort of. It looks like the change was the result of this commit (specifically, this line), which was to replace the (deprecated) Android function
getExternalStorageDirectory()
withgetExternalFilesDir()
instead. The resulting path change is then due to the differences in those two Android functions.You might find some of this stackoveflow discussion relevant too: https://stackoverflow.com/questions/10123812/difference-between-getexternalfilesdir-and-getexternalstoragedirectory
Cheers.