我想在Android中创建类似whatsapp的目录来存储一些文件.但是我无法在android中创建文件.我只能在我的包中创建文件/目录(例如com.exampleapp.org)…
我的目标是在android 4.3的“我的文档”目录中添加一个新文件…
在我的AndroidManifest.xml中,我设置了以下权限:WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE.
有人知道吗?是否可以通过“仅”电话间隙实现?还是我需要一个新插件?
我正在使用cordova 3.4.
谢谢.
解决方法:
要获取Documents目录,您应该使用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).