简体   繁体   English

Cordova - 如何访问设备存储?

[英]Cordova - How to access Device Storage?

I am developping an cordova application that contain a MP3 Player, for that, I have to get all MP3 files in the device, I know how to search in the SDCard (with cordova.file.externalRootDirectory) but, how to access to the classic Device Storage? 我正在开发一个包含MP3播放器的cordova应用程序,为此,我必须获取设备中的所有MP3文件,我知道如何在SDCard中搜索(使用cordova.file.externalRootDirectory)但是,如何访问经典设备存储? (Where there is "Android", "DCIM", "Download"... folders) (哪里有“Android”,“DCIM”,“下载”...文件夹)

Thanks in advance. 提前致谢。

EDIT: The cordova.file.dataDirectory doesn't works 编辑:cordova.file.dataDirectory不起作用

I'm using plugin cordova-plugin-file and it works for me to access to internal file storage 我正在使用插件cordova-plugin-file ,它可以让我访问内部文件存储

var folderpath = cordova.file.dataDirectory + "Download/";

Android directory structure Android目录结构

  • files: The application's internal file storage directory files:应用程序的内部文件存储目录
  • files-external: The application's external file storage directory files-external:应用程序的外部文件存储目录
  • sdcard: The global external file storage directory (this is the root of the SD card, if one is installed). sdcard:全局外部文件存储目录(如果安装了SD卡,则为SD卡的根目录)。 You must have the android.permission.WRITE_EXTERNAL_STORAGE permission to use this. 您必须具有android.permission.WRITE_EXTERNAL_STORAGE权限才能使用此权限。
  • cache: The application's internal cache directory cache:应用程序的内部缓存目录
  • cache-external: The application's external cache directory cache-external:应用程序的外部缓存目录
  • assets: The application's bundle (read-only) assets:应用程序的包(只读)
  • root: The entire device filesystem root:整个设备文件系统
  • applicationDirectory: ReadOnly with restricted access. applicationDirectory:具有受限访问权限的ReadOnly。 Copying files in this directory is possible, but reading it directly results in 'file not found'. 可以复制此目录中的文件,但直接读取会导致“找不到文件”。 Android also supports a special filesystem named "documents", which represents a "/Documents/" subdirectory within the "files" filesystem. Android还支持名为“documents”的特殊文件系统,它代表“files”文件系统中的“/ Documents /”子目录。

More information in Apache doc Apache doc中的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM