Does QStandardPaths work with sdcard on Android?
-
Provided "/mnt/sdcard/Download/file" exists, doing this gives me an empty path:
@QString path = QStandardPaths::locate(QStandardPaths::DownloadLocation, QStringLiteral("file"));@
How do I search standard locations on the SD card?
-
I don't know how it works QStandardPath, but for solving your problem I used a different approach calling directly the Android APIs using the androidextras module:
QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;"); QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" ); QString dataAbsPath = mediaPath.toString()+"/Download/"; QAndroidJniEnvironment env; if (env->ExceptionCheck()) { // Handle exception here. env->ExceptionClear(); }
-
Thanks Gianluca, that's probably what I'll have to do.
-
[quote author="Gianluca" date="1385969557"]I don't know how it works QStandardPath, but for solving your problem I used a different approach calling directly the Android APIs using the androidextras module:
@
QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
QString dataAbsPath = mediaPath.toString()+"/Download/";
QAndroidJniEnvironment env;
if (env->ExceptionCheck()) {
// Handle exception here.
env->ExceptionClear();
}
@
[/quote]Could I get the default location of android with androidextras ?Like the folders show by gallery?
-
I don't know what you need, but the general answer is that everything accessible using the android APIs are accessible using androidextras.
So, to find your answer take a look to the android developer APIs:
http://developer.android.com/reference/android/os/Environment.html