android - 如何像Whatsapp一样在我的文档文件夹中添加文件?

标签 android cordova

我想在android中创建一个类似whatsapp的目录来存储一些文件。但我无法在 android 中创建文件。我只能在我的包中创建文件/目录(例如 com.exampleapp.org)...

我的目标是在 android 4.3 的“我的文档”目录中添加一个新文件...

在我的 AndroidManifest.xml 中,我设置了以下权限:WRITE_EXTERNAL_STORAGEREAD_EXTERNAL_STORAGE

有人有想法吗? “仅”phonegap 是否可行,或者我需要一个新插件吗?

我正在使用 cordova 3.4。

谢谢。

最佳答案

要获取文档目录,您应该使用 Environment.DIRECTORY_DOCUMENTS .

访问它:

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)

Standard directory in which to place documents that have been created by the user.

其他目录:

public static String DIRECTORY_ALARMS Standard directory in which to place any audio files that should be in the list of alarms that the user can select (not as regular music).

public static String DIRECTORY_DCIM The traditional location for pictures and videos when mounting the device as a camera.

public static String DIRECTORY_DOCUMENTS Standard directory in which to place documents that have been created by the user.

public static String DIRECTORY_DOWNLOADS Standard directory in which to place files that have been downloaded by the user.

public static String DIRECTORY_MOVIES Standard directory in which to place movies that are available to the user.

public static String DIRECTORY_MUSIC Standard directory in which to place any audio files that should be in the regular list of music for the user. public static String DIRECTORY_NOTIFICATIONS Standard directory in which to place any audio files that should be in the list of notifications that the user can select (not as regular music).

public static String DIRECTORY_PICTURES Standard directory in which to place pictures that are available to the user.

public static String DIRECTORY_PODCASTS Standard directory in which to place any audio files that should be in the list of podcasts that the user can select (not as regular music).

public static String DIRECTORY_RINGTONES Standard directory in which to place any audio files that should be in the list of ringtones that the user can select (not as regular music).

关于android - 如何像Whatsapp一样在我的文档文件夹中添加文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22965123/

相关文章:

android - 无论如何要从 View 对象中删除 onTouchListener 吗?

cordova - iPhone 上的 Phonegap + Jquery Mobile changePage 在登陆到所需页面之前总是会出现白色闪烁

android - 使用 PhoneGap 创建项目时出现问题

javascript - 如何使用 localstorage 使用 javascript 登录

android - 动态创建布局

android:inputType ="textAutoComplete"不起作用

android - Android-MenuDrawer 编译错误

android - 使布局在所有设备上看起来都不错

javascript - 适用于移动设备上所有视频文件的 Phonegap/Cordova 视频播放器

Android:包含 ZXing 时出现 ClassNotFoundException