1. public class Environment {
  2.  
  3. /**
  4. * Return root of the "system" partition holding the core Android OS.
  5. * Always present and mounted read-only.
  6. */
  7. public static File getRootDirectory()
  8.  
  9. /**
  10. * Return root directory of the "oem" partition holding OEM customizations,
  11. * if any. If present, the partition is mounted read-only.
  12. *
  13. * @hide
  14. */
  15. public static File getOemDirectory()
  16.  
  17. /**
  18. * Return root directory of the "vendor" partition that holds vendor-provided
  19. * software that should persist across simple reflashing of the "system" partition.
  20. * @hide
  21. */
  22. public static File getVendorDirectory()
  23.  
  24. /**
  25. * Gets the system directory available for secure storage.
  26. * If Encrypted File system is enabled, it returns an encrypted directory (/data/secure/system).
  27. * Otherwise, it returns the unencrypted /data/system directory.
  28. * @return File object representing the secure storage system directory.
  29. * @hide
  30. */
  31. public static File getSystemSecureDirectory()
  32.  
  33. /**
  34. * Gets the data directory for secure storage.
  35. * If Encrypted File system is enabled, it returns an encrypted directory (/data/secure).
  36. * Otherwise, it returns the unencrypted /data directory.
  37. * @return File object representing the data directory for secure storage.
  38. * @hide
  39. */
  40. public static File getSecureDataDirectory()
  41.  
  42. /**
  43. * Return directory used for internal media storage, which is protected by
  44. * {@link android.Manifest.permission#WRITE_MEDIA_STORAGE}.
  45. *
  46. * @hide
  47. */
  48. public static File getMediaStorageDirectory()
  49.  
  50. /**
  51. * Return the system directory for a user. This is for use by system services to store
  52. * files relating to the user. This directory will be automatically deleted when the user
  53. * is removed.
  54. *
  55. * @hide
  56. */
  57. public static File getUserSystemDirectory(int userId)
  58.  
  59. /**
  60. * Returns the config directory for a user. This is for use by system services to store files
  61. * relating to the user which should be readable by any app running as that user.
  62. *
  63. * @hide
  64. */
  65. public static File getUserConfigDirectory(int userId)
  66.  
  67. /**
  68. * Returns whether the Encrypted File System feature is enabled on the device or not.
  69. * @return <code>true</code> if Encrypted File System feature is enabled, <code>false</code>
  70. * if disabled.
  71. * @hide
  72. */
  73. public static boolean isEncryptedFilesystemEnabled()
  74.  
  75. private static final File DATA_DIRECTORY
  76. = getDirectory("ANDROID_DATA", "/data");
  77.  
  78. /**
  79. * @hide
  80. */
  81. private static final File SECURE_DATA_DIRECTORY
  82. = getDirectory("ANDROID_SECURE_DATA", "/data/secure");
  83.  
  84. private static final File DOWNLOAD_CACHE_DIRECTORY = getDirectory("DOWNLOAD_CACHE", "/cache");
  85.  
  86. /**
  87. * Return the user data directory.
  88. */
  89. public static File getDataDirectory()
  90.  
  91. /**
  92. * Return the primary external storage directory. This directory may not
  93. * currently be accessible if it has been mounted by the user on their
  94. * computer, has been removed from the device, or some other problem has
  95. * happened. You can determine its current state with
  96. * {@link #getExternalStorageState()}.
  97. * <p>
  98. * <em>Note: don't be confused by the word "external" here. This directory
  99. * can better be thought as media/shared storage. It is a filesystem that
  100. * can hold a relatively large amount of data and that is shared across all
  101. * applications (does not enforce permissions). Traditionally this is an SD
  102. * card, but it may also be implemented as built-in storage in a device that
  103. * is distinct from the protected internal storage and can be mounted as a
  104. * filesystem on a computer.</em>
  105. * <p>
  106. * On devices with multiple users (as described by {@link UserManager}),
  107. * each user has their own isolated external storage. Applications only have
  108. * access to the external storage for the user they're running as.
  109. * <p>
  110. * In devices with multiple "external" storage directories, this directory
  111. * represents the "primary" external storage that the user will interact
  112. * with. Access to secondary storage is available through
  113. * <p>
  114. * Applications should not directly use this top-level directory, in order
  115. * to avoid polluting the user's root namespace. Any files that are private
  116. * to the application should be placed in a directory returned by
  117. * {@link android.content.Context#getExternalFilesDir
  118. * Context.getExternalFilesDir}, which the system will take care of deleting
  119. * if the application is uninstalled. Other shared files should be placed in
  120. * one of the directories returned by
  121. * {@link #getExternalStoragePublicDirectory}.
  122. * <p>
  123. * Writing to this path requires the
  124. * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission,
  125. * and starting in read access requires the
  126. * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission,
  127. * which is automatically granted if you hold the write permission.
  128. * <p>
  129. * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, if your
  130. * application only needs to store internal data, consider using
  131. * {@link Context#getExternalFilesDir(String)} or
  132. * {@link Context#getExternalCacheDir()}, which require no permissions to
  133. * read or write.
  134. * <p>
  135. * This path may change between platform versions, so applications should
  136. * only persist relative paths.
  137. * <p>
  138. * Here is an example of typical code to monitor the state of external
  139. * storage:
  140. * <p>
  141. * {@sample
  142. * development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
  143. * monitor_storage}
  144. *
  145. * @see #getExternalStorageState()
  146. * @see #isExternalStorageRemovable()
  147. */
  148. public static File getExternalStorageDirectory()
  149.  
  150. /** {@hide} */
  151. public static File getLegacyExternalStorageDirectory()
  152.  
  153. /** {@hide} */
  154. public static File getLegacyExternalStorageObbDirectory()
  155.  
  156. /** {@hide} */
  157. public static File getEmulatedStorageSource(int userId)
  158.  
  159. /** {@hide} */
  160. public static File getEmulatedStorageObbSource()
  161.  
  162. /**
  163. * Standard directory in which to place any audio files that should be
  164. * in the regular list of music for the user.
  165. * This may be combined with
  166. * {@link #DIRECTORY_PODCASTS}, {@link #DIRECTORY_NOTIFICATIONS},
  167. * {@link #DIRECTORY_ALARMS}, and {@link #DIRECTORY_RINGTONES} as a series
  168. * of directories to categories a particular audio file as more than one
  169. * type.
  170. */
  171. public static String DIRECTORY_MUSIC = "Music";
  172.  
  173. /**
  174. * Standard directory in which to place any audio files that should be
  175. * in the list of podcasts that the user can select (not as regular
  176. * music).
  177. * This may be combined with {@link #DIRECTORY_MUSIC},
  178. * {@link #DIRECTORY_NOTIFICATIONS},
  179. * {@link #DIRECTORY_ALARMS}, and {@link #DIRECTORY_RINGTONES} as a series
  180. * of directories to categories a particular audio file as more than one
  181. * type.
  182. */
  183. public static String DIRECTORY_PODCASTS = "Podcasts";
  184.  
  185. /**
  186. * Standard directory in which to place any audio files that should be
  187. * in the list of ringtones that the user can select (not as regular
  188. * music).
  189. * This may be combined with {@link #DIRECTORY_MUSIC},
  190. * {@link #DIRECTORY_PODCASTS}, {@link #DIRECTORY_NOTIFICATIONS}, and
  191. * {@link #DIRECTORY_ALARMS} as a series
  192. * of directories to categories a particular audio file as more than one
  193. * type.
  194. */
  195. public static String DIRECTORY_RINGTONES = "Ringtones";
  196.  
  197. /**
  198. * Standard directory in which to place any audio files that should be
  199. * in the list of alarms that the user can select (not as regular
  200. * music).
  201. * This may be combined with {@link #DIRECTORY_MUSIC},
  202. * {@link #DIRECTORY_PODCASTS}, {@link #DIRECTORY_NOTIFICATIONS},
  203. * and {@link #DIRECTORY_RINGTONES} as a series
  204. * of directories to categories a particular audio file as more than one
  205. * type.
  206. */
  207. public static String DIRECTORY_ALARMS = "Alarms";
  208.  
  209. /**
  210. * Standard directory in which to place any audio files that should be
  211. * in the list of notifications that the user can select (not as regular
  212. * music).
  213. * This may be combined with {@link #DIRECTORY_MUSIC},
  214. * {@link #DIRECTORY_PODCASTS},
  215. * {@link #DIRECTORY_ALARMS}, and {@link #DIRECTORY_RINGTONES} as a series
  216. * of directories to categories a particular audio file as more than one
  217. * type.
  218. */
  219. public static String DIRECTORY_NOTIFICATIONS = "Notifications";
  220.  
  221. /**
  222. * Standard directory in which to place pictures that are available to
  223. * the user. Note that this is primarily a convention for the top-level
  224. * public directory, as the media scanner will find and collect pictures
  225. * in any directory.
  226. */
  227. public static String DIRECTORY_PICTURES = "Pictures";
  228.  
  229. /**
  230. * Standard directory in which to place movies that are available to
  231. * the user. Note that this is primarily a convention for the top-level
  232. * public directory, as the media scanner will find and collect movies
  233. * in any directory.
  234. */
  235. public static String DIRECTORY_MOVIES = "Movies";
  236.  
  237. /**
  238. * Standard directory in which to place files that have been downloaded by
  239. * the user. Note that this is primarily a convention for the top-level
  240. * public directory, you are free to download files anywhere in your own
  241. * private directories. Also note that though the constant here is
  242. * named DIRECTORY_DOWNLOADS (plural), the actual file name is non-plural for
  243. * backwards compatibility reasons.
  244. */
  245. public static String DIRECTORY_DOWNLOADS = "Download";
  246.  
  247. /**
  248. * The traditional location for pictures and videos when mounting the
  249. * device as a camera. Note that this is primarily a convention for the
  250. * top-level public directory, as this convention makes no sense elsewhere.
  251. */
  252. public static String DIRECTORY_DCIM = "DCIM";
  253.  
  254. /**
  255. * Standard directory in which to place documents that have been created by
  256. * the user.
  257. */
  258. public static String DIRECTORY_DOCUMENTS = "Documents";
  259.  
  260. /**
  261. * Get a top-level public external storage directory for placing files of
  262. * a particular type. This is where the user will typically place and
  263. * manage their own files, so you should be careful about what you put here
  264. * to ensure you don't erase their files or get in the way of their own
  265. * organization.
  266. *
  267. * <p>On devices with multiple users (as described by {@link UserManager}),
  268. * each user has their own isolated external storage. Applications only
  269. * have access to the external storage for the user they're running as.</p>
  270. *
  271. * <p>Here is an example of typical code to manipulate a picture on
  272. * the public external storage:</p>
  273. *
  274. * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
  275. * public_picture}
  276. *
  277. * @param type The type of storage directory to return. Should be one of
  278. * {@link #DIRECTORY_MUSIC}, {@link #DIRECTORY_PODCASTS},
  279. * {@link #DIRECTORY_RINGTONES}, {@link #DIRECTORY_ALARMS},
  280. * {@link #DIRECTORY_NOTIFICATIONS}, {@link #DIRECTORY_PICTURES},
  281. * {@link #DIRECTORY_MOVIES}, {@link #DIRECTORY_DOWNLOADS}, or
  282. * {@link #DIRECTORY_DCIM}. May not be null.
  283. *
  284. * @return Returns the File path for the directory. Note that this
  285. * directory may not yet exist, so you must make sure it exists before
  286. * using it such as with {@link File#mkdirs File.mkdirs()}.
  287. */
  288. public static File getExternalStoragePublicDirectory(String type)
  289.  
  290. /**
  291. * Returns the path for android-specific data on the SD card.
  292. * @hide
  293. */
  294. public static File[] buildExternalStorageAndroidDataDirs()
  295.  
  296. /**
  297. * Generates the raw path to an application's data
  298. * @hide
  299. */
  300. public static File[] buildExternalStorageAppDataDirs(String packageName)
  301.  
  302. /**
  303. * Generates the raw path to an application's media
  304. * @hide
  305. */
  306. public static File[] buildExternalStorageAppMediaDirs(String packageName)
  307. /**
  308. * Generates the raw path to an application's OBB files
  309. * @hide
  310. */
  311. public static File[] buildExternalStorageAppObbDirs(String packageName)
  312. /**
  313. * Generates the path to an application's files.
  314. * @hide
  315. */
  316. public static File[] buildExternalStorageAppFilesDirs(String packageName)
  317.  
  318. /**
  319. * Generates the path to an application's cache.
  320. * @hide
  321. */
  322. public static File[] buildExternalStorageAppCacheDirs(String packageName)
  323.  
  324. /**
  325. * Return the download/cache content directory.
  326. */
  327. public static File getDownloadCacheDirectory()
  328.  
  329. /**
  330. * Unknown storage state, such as when a path isn't backed by known storage
  331. * media.
  332. *
  333. * @see #getExternalStorageState(File)
  334. */
  335. public static final String MEDIA_UNKNOWN = "unknown";
  336.  
  337. /**
  338. * Storage state if the media is not present.
  339. *
  340. * @see #getExternalStorageState(File)
  341. */
  342. public static final String MEDIA_REMOVED = "removed";
  343.  
  344. /**
  345. * Storage state if the media is present but not mounted.
  346. *
  347. * @see #getExternalStorageState(File)
  348. */
  349. public static final String MEDIA_UNMOUNTED = "unmounted";
  350.  
  351. /**
  352. * Storage state if the media is present and being disk-checked.
  353. *
  354. * @see #getExternalStorageState(File)
  355. */
  356. public static final String MEDIA_CHECKING = "checking";
  357.  
  358. /**
  359. * Storage state if the media is present but is blank or is using an
  360. * unsupported filesystem.
  361. *
  362. * @see #getExternalStorageState(File)
  363. */
  364. public static final String MEDIA_NOFS = "nofs";
  365.  
  366. /**
  367. * Storage state if the media is present and mounted at its mount point with
  368. * read/write access.
  369. *
  370. * @see #getExternalStorageState(File)
  371. */
  372. public static final String MEDIA_MOUNTED = "mounted";
  373.  
  374. /**
  375. * Storage state if the media is present and mounted at its mount point with
  376. * read-only access.
  377. *
  378. * @see #getExternalStorageState(File)
  379. */
  380. public static final String MEDIA_MOUNTED_READ_ONLY = "mounted_ro";
  381.  
  382. /**
  383. * Storage state if the media is present not mounted, and shared via USB
  384. * mass storage.
  385. *
  386. * @see #getExternalStorageState(File)
  387. */
  388. public static final String MEDIA_SHARED = "shared";
  389.  
  390. /**
  391. * Storage state if the media was removed before it was unmounted.
  392. *
  393. * @see #getExternalStorageState(File)
  394. */
  395. public static final String MEDIA_BAD_REMOVAL = "bad_removal";
  396.  
  397. /**
  398. * Storage state if the media is present but cannot be mounted. Typically
  399. * this happens if the file system on the media is corrupted.
  400. *
  401. * @see #getExternalStorageState(File)
  402. */
  403. public static final String MEDIA_UNMOUNTABLE = "unmountable";
  404.  
  405. /**
  406. * Returns the current state of the primary "external" storage device.
  407. *
  408. * @see #getExternalStorageDirectory()
  409. * @return one of {@link #MEDIA_UNKNOWN}, {@link #MEDIA_REMOVED},
  410. * {@link #MEDIA_UNMOUNTED}, {@link #MEDIA_CHECKING},
  411. * {@link #MEDIA_NOFS}, {@link #MEDIA_MOUNTED},
  412. * {@link #MEDIA_MOUNTED_READ_ONLY}, {@link #MEDIA_SHARED},
  413. * {@link #MEDIA_BAD_REMOVAL}, or {@link #MEDIA_UNMOUNTABLE}.
  414. */
  415. public static String getExternalStorageState()
  416.  
  417. /**
  418. * @deprecated use {@link #getExternalStorageState(File)}
  419. */
  420. @Deprecated
  421. public static String getStorageState(File path)
  422.  
  423. /**
  424. * Returns the current state of the storage device that provides the given
  425. * path.
  426. *
  427. * @return one of {@link #MEDIA_UNKNOWN}, {@link #MEDIA_REMOVED},
  428. * {@link #MEDIA_UNMOUNTED}, {@link #MEDIA_CHECKING},
  429. * {@link #MEDIA_NOFS}, {@link #MEDIA_MOUNTED},
  430. * {@link #MEDIA_MOUNTED_READ_ONLY}, {@link #MEDIA_SHARED},
  431. * {@link #MEDIA_BAD_REMOVAL}, or {@link #MEDIA_UNMOUNTABLE}.
  432. */
  433. public static String getExternalStorageState(File path)
  434.  
  435. /**
  436. * Returns whether the primary "external" storage device is removable.
  437. *
  438. * @return true if the storage device can be removed (such as an SD card),
  439. * or false if the storage device is built in and cannot be
  440. * physically removed.
  441. */
  442. public static boolean isExternalStorageRemovable()
  443.  
  444. /**
  445. * Returns whether the storage device that provides the given path is
  446. * removable.
  447. *
  448. * @return true if the storage device can be removed (such as an SD card),
  449. * or false if the storage device is built in and cannot be
  450. * physically removed.
  451. * @throws IllegalArgumentException if the path is not a valid storage
  452. * device.
  453. */
  454. public static boolean isExternalStorageRemovable(File path)
  455.  
  456. /**
  457. * Returns whether the primary "external" storage device is emulated. If
  458. * true, data stored on this device will be stored on a portion of the
  459. * internal storage system.
  460. *
  461. * @see DevicePolicyManager#setStorageEncryption(android.content.ComponentName,
  462. * boolean)
  463. */
  464. public static boolean isExternalStorageEmulated()
  465.  
  466. /**
  467. * Returns whether the storage device that provides the given path is
  468. * emulated. If true, data stored on this device will be stored on a portion
  469. * of the internal storage system.
  470. *
  471. * @throws IllegalArgumentException if the path is not a valid storage
  472. * device.
  473. */
  474. public static boolean isExternalStorageEmulated(File path)
  475.  
  476. static File getDirectory(String variableName, String defaultPath)
  477. /** {@hide} */
  478. public static void setUserRequired(boolean userRequired)
  479.  
  480. /**
  481. * Append path segments to each given base path, returning result.
  482. *
  483. * @hide
  484. */
  485. public static File[] buildPaths(File[] base, String... segments)
  486.  
  487. /**
  488. * Append path segments to given base path, returning result.
  489. *
  490. * @hide
  491. */
  492. public static File buildPath(File base, String... segments)
  493.  
  494. private static boolean isStorageDisabled()
  495.  
  496. private static StorageVolume getStorageVolume(File path)
  497.  
  498. /**
  499. * If the given path exists on emulated external storage, return the
  500. * translated backing path hosted on internal storage. This bypasses any
  501. * emulation later, improving performance. This is <em>only</em> suitable
  502. * for read-only access.
  503. * <p>
  504. * Returns original path if given path doesn't meet these criteria. Callers
  505. * must hold {@link android.Manifest.permission#WRITE_MEDIA_STORAGE}
  506. * permission.
  507. *
  508. * @hide
  509. */
  510. public static File maybeTranslateEmulatedPathToInternal(File path)
  511. }

Environment中有大量访问目录的函数的更多相关文章

  1. windows中操作文件和目录的函数

    1.文件操作函数       CreateFile();//创建或打开文件      ReadFile();//从文件读      WriteFile();//向文件写      SetFilePoi ...

  2. VC遍历访问目录下的文件

    访问目录文件夹下的文件是经常需要的操作,C/C++和win32接口都没有提供直接调用的函数.在这里总结了几个经常用到的函数,通过MFC的CFileFind函数递归遍历实现,包括以下几个功能函数: 查找 ...

  3. linux回退到上次访问目录

    cd / cd ..  回到上级目录 cd - 回到上次访问目录

  4. 【Linux C中文函数手册】之 目录操作函数

    目录操作函数 1)closedir 关闭目录 相关函数: opendir表头文件: #include<sys/types.h> #include<dirent.h>定义函数: ...

  5. centos下配置sftp且限制用户访问目录[转]

    第一步:创建sftp服务用户组,创建sftp服务根目录 groupadd sftp #此目录及上级目录的所有者(owner)必须为root,权限不高于755,此目录的组最好设定为sftp mkdir ...

  6. linux 搭建ftp服务并设置限制访问目录

    服务器有好几个项目,新项目前端外包,因为要微信授权登陆,所以前端没有办法本地调试,必须上次ftp在我们服务器上调试代码,当然要限制ftp访问的目录,否则整个服务器项目都能看到了. 安装vsftpd s ...

  7. JNI的又一替代者—使用JNR访问Java外部函数接口(jnr-ffi)

    1. JNR简单介绍 继上文“JNI的替代者—使用JNA访问Java外部函数接口”,我们知道JNI越来越不受欢迎,JNI是编写Java本地方法以及将Java虚拟机嵌入本地应用程序的标准编程接口.它管理 ...

  8. centos下配置sftp且限制用户访问目录

    SFTP在Linux下是一个很方便很安全的文件传输工具,我常常用它在Linux服务器上替代传统的ftp来传输文件.众所周知SFTP账号是基于SSH账号的,默认情况下访问服务器的权限很大,下面的教程就是 ...

  9. nginx默认访问目录时显示403错误

    author :headsen chen date: 2018-04-25  17:17:25 nginx安装完成后默认的http页面里访问目录的话会报403的错误: 和Apache进行比较,Apac ...

随机推荐

  1. DosBox 报错 this program requires dosxnt.exe to be in your path

    也就是少了dosxnt.exe文件,能够上网搜索下载,把dosxnt 拷贝到你挂截文件夹下就能够执行 Dosxnt文件下载

  2. 怎样更好的设计你的REST API之基于REST架构的Web Service设计及REST框架实现

    一.REST 含状态传输(英文:Representational State Transfer,简称REST)是Roy Fielding博士在2000年他的博士论文中提出来的一种软件架构风格. 眼下在 ...

  3. HiWorkV1.3版震撼公布,今日起正式公开測试!

    今天HiWork迎来了公开測试和V1.3大版本号更迭,HiWork集成的机器人达到20种,未读消息提醒亦可从不同维度进行设置,不断变好真是件振奋人心的事儿呢. 在这个看重颜值(kan lian)的互联 ...

  4. Mac下Apache+MySQL+PHP安装

    max下是自带有Apache和php的服务器的,不需要另外安装,本文就对相关配置进行介绍. 第一:Apache 在终端中输入,下面指令即可启动Apache服务器: //启动 sudo apachect ...

  5. 辛星浅析一次ajax的实现过程

    说到ajax,那绝对是一个老生常谈的话题,近些年ajax技术的使用颇为盛行. 以下我们就以jQuery为例来从一个真实的项目中看一下ajax的实例. 首先是前端页面,这个页面我们使用的是bootstr ...

  6. caution

    做好需求更改的准备,提高代码的扩展性和可维护性:预留出修改bug和需求的时间:对需求理解透彻再开始写代码:代码不要写死,防止需求变动. 

  7. CRM 配置 ADFS后,使用自定义STS遇到的问题总结

    1 登录ADFS服务查看 ADFS日志 2 根据日志提示的错误,设置ADFS对应的属性 (Get-ADFSRelyingPartyTrust) | Set-ADFSRelyingPartyTrust  ...

  8. Oracle - 数据更新 - 增删改

    /* 数据的更新 增加 删除 修改 */ -----------------------------------增加(一次只能插入一条数据) --自定义插入数据列的顺序 ,,); --按照数据库默认的 ...

  9. div内鼠标坐标位置及绝对和相对坐标获取

    JQuery 获得div绝对,相对位置的坐标方法   1 2 3 4 5 6 获取页面某一元素的绝对X,Y坐标 var X = $('#DivID').offset().top; var Y = $( ...

  10. 织梦仿站列表页pagelist分页显示竖排,如何修改成横排?

    织梦仿站列表页pagelist分页显示竖排,如何修改成横排? 织梦列表页的分页标签是采用pagelist来进行调用的,但是很多人在调用之后会出现一个列表竖着排列的问题(横排美观度好一些),还是非常不美 ...