Cannot create folder or save files on android devices(API level >=29)
-
Sir, could you give me information to solve this problem
-
@jsulm said in Cannot save files on android devices(API level >=29):
to request write access to Music storage
solved the issue...
For Android 10 and 11, you can add android:requestLegacyExternalStorage="true" to your <application> element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work. -
@NIvil-Wilson said in Cannot save files on android devices(API level >=29):
could you give me information to solve this problem
Can you provide more information please?
Where exactly are you trying to store files?
Did you request the rights to store files there? -
@jsulm sir,
I tried to save the file in QStandardPaths::MusicLocation and have run time permissions too. The application works well in android devices which has an API level <=28.But on android devices which has API level >=29 it fails to create folder and file in Music Folder (QStandardPaths::MusicLocation) .At debug time it shows file not accessible.sorry for my bad english.code_text <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.RECORD_AUDIO"/> ************************************************************************************ auto result = QtAndroid::checkPermission(QString("android.permission.WRITE_EXTERNAL_STORAGE")); if(result == QtAndroid::PermissionResult::Denied){ QtAndroid::PermissionResultMap resultHash = QtAndroid::requestPermissionsSync(QStringList({"android.permission.WRITE_EXTERNAL_STORAGE"})); if(resultHash["android.permission.WRITE_EXTERNAL_STORAGE"] == QtAndroid::PermissionResult::Denied) return 0; } auto result1 = QtAndroid::checkPermission(QString("android.permission.RECORD_AUDIO")); if(result1 == QtAndroid::PermissionResult::Denied){ QtAndroid::PermissionResultMap resultHash1 = QtAndroid::requestPermissionsSync(QStringList({"android.permission.RECORD_AUDIO"})); if(resultHash1["android.permission.RECORD_AUDIO"] == QtAndroid::PermissionResult::Denied) return 0; }
-
@NIvil-Wilson I'm not Android expert, but maybe you need to request write access to Music storage?
-
@jsulm said in Cannot save files on android devices(API level >=29):
to request write access to Music storage
solved the issue...
For Android 10 and 11, you can add android:requestLegacyExternalStorage="true" to your <application> element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work. -
@NIvil-Wilson ,You are saved my week. Thanks
-