我想在android中创建一个类似whatsapp的目录来存储一些文件。但我无法在 android 中创建文件。我只能在我的包中创建文件/目录(例如 com.exampleapp.org)...
我的目标是在 android 4.3 的“我的文档”目录中添加一个新文件...
在我的 AndroidManifest.xml 中,我设置了以下权限:WRITE_EXTERNAL_STORAGE
、READ_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/