[英]Android device directory not creating when i set target api as 29
我在 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需要在配置或 android 清單文件中添加任何內容嗎? 或者需要添加權限才能使用 API 29.
感謝您的幫助,因為我已經被困在這幾天了。
問候,
阿拉文
雖然我不是 Cordova 專家,但問題似乎是因為作為 API 29 (Android 10) 的一部分引入的范圍存儲
它對您的應用程序如何讀取/寫入文件系統添加了一些限制。 但是,作為一種變通方法,您可以選擇退出 Scoped Storage 以像 API 28 一樣工作。
只需在清單文件的應用程序標簽中添加android:requestLegacyExternalStorage="true"
即可選擇退出范圍存儲。 它應該可以解決您的問題。
確保您的 compileSdkVersion 設置為 29 以使用此屬性。
請注意,如果您以 API 30 (Android 11) 為目標,系統將忽略此標志,您必須使您的應用與范圍存儲兼容。
更多信息:https://developer.android.com/about/versions/11/privacy/storage
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.