[英]Android device directory not creating when i set target api as 29
i have a mobile app in cordova, in that i create directory, if i use Target Api 28, it will create folder, in same time if set Target Api as 29,directory never creating, i am using following code to create directory in internal storage.我在 cordova 中有一个移动应用程序,在那里我创建目录,如果我使用 Target Api 28,它将创建文件夹,同时如果在内部设置 Target Z72664DC0959F3B0C04891F8C7046A9F 目录,创建以下代码为 293,贮存。
if (device.platform.toLowerCase() == "android") {
window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, onFileSystemSuccess, onError);
} else {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onError);
}
function onFileSystemSuccess(fileSystem) {
var entry = "";
if (device.platform.toLowerCase() == "android") {
entry = fileSystem;
} else {
entry = fileSystem.root;
}
entry.getDirectory("smfolder", {
create: true,
exclusive: false
}, onGetDirectorySuccess, onGetDirectoryFail);
};
function onError(e) {
alert("Fail to get folder");
};
This is config.xml screenshot: http://prntscr.com/w53qgh When i upload in Play Store, it will ask to set Target Api level as 29, then only can upload, so i need to set API as 29, is there any thing need to add in config or android manifest file? This is config.xml screenshot: http://prntscr.com/w53qgh When i upload in Play Store, it will ask to set Target Api level as 29, then only can upload, so i need to set API as 29, is there需要在配置或 android 清单文件中添加任何内容吗? or need to add permission to use API 29.
或者需要添加权限才能使用 API 29.
Appreciate your assistance since i have been stuck in this for few days now.感谢您的帮助,因为我已经被困在这几天了。
Regards,问候,
Aravind阿拉文
Although I am not a Cordova expert, it seems that the issue is because of Scoped Storage introduced as part of API 29 (Android 10)虽然我不是 Cordova 专家,但问题似乎是因为作为 API 29 (Android 10) 的一部分引入的范围存储
It adds some restrictions on how your app can read/write to file system.它对您的应用程序如何读取/写入文件系统添加了一些限制。 However, as a work-around, you can opt-out of Scoped Storage to work just like API 28.
但是,作为一种变通方法,您可以选择退出 Scoped Storage 以像 API 28 一样工作。
Just add android:requestLegacyExternalStorage="true"
in manifest file's application tag to opt-out of scoped storage.只需在清单文件的应用程序标签中添加
android:requestLegacyExternalStorage="true"
即可选择退出范围存储。 It should solve your problem.它应该可以解决您的问题。
Make sure your compileSdkVersion is set to 29 to use this attribute.确保您的 compileSdkVersion 设置为 29 以使用此属性。
Please note that if you target API 30 (Android 11), this flag will be ignored by the system and you have to make your app compatible with scoped storage.请注意,如果您以 API 30 (Android 11) 为目标,系统将忽略此标志,您必须使您的应用与范围存储兼容。
More on:https://developer.android.com/about/versions/11/privacy/storage更多信息:https://developer.android.com/about/versions/11/privacy/storage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.