在没有挂载前存储媒体已经被移除。 |
||
正在检查存储媒体。 |
||
存储媒体已经挂载,并且挂载点可读/写。 |
||
存储媒体已经挂载,挂载点只读。 |
||
存储媒体是空白或是不支持的文件系统。 |
||
存储媒体被移除。 |
||
存储媒体正在通过USB共享。 |
||
存储媒体无法挂载。 |
||
存储媒体没有挂载。 |
public static String |
系统提醒铃声存放的标准目录。 |
|
public static String |
相机拍摄照片和视频的标准目录。 |
|
public static String |
下载的标准目录。 |
|
public static String |
电影存放的标准目录。 |
|
public static String |
音乐存放的标准目录。 |
|
public static String |
系统通知铃声存放的标准目录。 |
|
public static String |
图片存放的标准目录。 |
|
public static String |
系统广播存放的标准目录。 |
|
public static String |
系统铃声存放的标准目录。 |
static File |
获得android data的目录。 |
static File |
获得下载缓存目录。 |
static File |
或者外部存储媒体目录。 |
static File |
getExternalStoragePublicDirectory(String type) Get a top-level public external storage directory for placing files of a particular type. |
static String |
获得当前外部储存媒体的状态。 |
static File |
获得android的跟目录。 |
public static File getExternalStoragePublicDirectory (String type)
Get a top-level public external storage directory for placing files of a particular type. This is where the user will typically place and manage their own files, so you should be careful about what you put here to ensure you don't erase their files or get in the way of their own organization.
Here is an example of typical code to manipulate a picture on the public external storage:
void createExternalStoragePublicPicture(){// Create a path where we will place our picture in the user's// public pictures directory. Note that you should be careful about// what you place here, since the user often manages these files. For// pictures and other media owned by the application, consider// Context.getExternalMediaDir().File path =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);File file =newFile(path,"DemoPicture.jpg");try{// Make sure the Pictures directory exists. path.mkdirs();// Very simple code to copy a picture from the application's// resource into the external file. Note that this code does// no error checking, and assumes the picture is small (does not// try to copy it in chunks). Note that if external storage is// not currently mounted this will silently fail.InputStreamis= getResources().openRawResource(R.drawable.balloons);OutputStream os =newFileOutputStream(file);byte[] data =newbyte[is.available()];is.read(data); os.write(data);is.close(); os.close();// Tell the media scanner about the new file so that it is // 这一步非常重要!!// immediately available to the user.MediaScannerConnection.scanFile(this,newString[]{ file.toString()},null,newMediaScannerConnection.OnScanCompletedListener(){publicvoid onScanCompleted(String path,Uri uri){Log.i("ExternalStorage","Scanned "+ path +":");Log.i("ExternalStorage","-> uri="+ uri);}});}catch(IOException e){// Unable to create file, likely because external storage is// not currently mounted.Log.w("ExternalStorage","Error writing "+ file, e);}}void deleteExternalStoragePublicPicture(){// Create a path where we will place our picture in the user's// public pictures directory and delete the file. If external// storage is not currently mounted this will fail.File path =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);File file =newFile(path,"DemoPicture.jpg"); file.delete();}boolean hasExternalStoragePublicPicture(){// Create a path where we will place our picture in the user's// public pictures directory and check if the file exists. If// external storage is not currently mounted this will think the// picture doesn't exist.File path =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);File file =newFile(path,"DemoPicture.jpg");return file.exists();}
Parameters
The type of storage directory to return. Should be one ofDIRECTORY_MUSIC ,DIRECTORY_PODCASTS ,DIRECTORY_RINGTONES ,DIRECTORY_ALARMS ,DIRECTORY_NOTIFICATIONS ,DIRECTORY_PICTURES ,DIRECTORY_MOVIES ,DIRECTORY_DOWNLOADS , orDIRECTORY_DCIM . May not be null. |
Returns
- Returns the File path for the directory. Note that this directory may not yet exist, so you must make sure it exists before using it such as with
File.mkdirs()
.
以上内容摘自google android开发文
相关推荐
android_environment5android_environment5
android中的Environment的使用说明,讲解了此类的大部分函数的使用和变量的说明
在IT行业中,Android开发环境是开发者构建和调试Android应用程序的基础。Android开发环境主要由几个关键组件构成,包括Java或Kotlin编程语言、Android Studio集成开发环境(IDE)、Android SDK(软件开发工具包)...
`ChangeEnvironment`可能会提供自动化工具来处理这类替换。 总的来说,`Android-ChangeEnvironment`项目是Android开发者的好帮手,它简化了环境管理和多渠道打包的流程,提高了开发效率,使得开发者可以更加专注于...
android_environment4android_environment4
android_environment3android_environment3
android_environment2android_environment2
android_environment1android_environment1
这个"android_environment.zip"文件正是为了帮助初学者快速、顺利地完成这一过程。本文将详细解析这个压缩包内的"android环境配置.doc"文档所涵盖的知识点,并提供一份详尽的Android开发环境配置指南。 1. **Java ...
### Android SDK 开发环境搭建详解 #### 一、概述 Android SDK(Software Development Kit)是谷歌为Android开发者提供的工具包,包含了一系列开发Android应用程序所需的工具和库。搭建一个完整的Android SDK开发...
2. **Environment类**:在Android中,`Environment`类提供了访问外部存储路径的静态方法,如`getExternalStorageDirectory()`用于获取外部存储根目录,`getDownloadCacheDirectory()`用于获取下载缓存目录。...
`Environment`是Android提供的一个系统类,它提供了与文件系统相关的常量和方法,而`StatFs`则用于获取文件系统的统计信息,包括可用空间、总空间等。 首先,让我们了解`Environment`类。这个类位于`android.os`包...
在本文中,我们将深入探讨如何在Ubuntu 14.04 64位操作系统上搭建Android编译环境,特别以MTK平台为例,但同样适合其他平台。通过本文档的操作步骤,我们可以成功安装并配置Android 5.0/6.0的编译环境。 ### 操作...
"Environment_android_"这个标题暗示了本教程主要涉及的内容,即为Android开发配置必要的环境。这通常包括安装Java Development Kit (JDK),设置Java环境变量,下载并安装Android Studio,配置Android SDK,以及安装...
本文档是关于在Ubuntu 14.04 64位操作系统上设置Android基于产品的构建环境的安装标准操作程序(SOP)。该文档主要关注的是Android 6.0及以后版本的编译环境,以MTK(联发科技)平台为例进行说明,同时提到其他平台可...
### 关于Google Android作为DTV解码系统应用环境的知识点 #### 一、引言与背景 随着技术的进步和发展,数字电视(DTV)设备及其相关的机顶盒已经成为了现代家庭娱乐的重要组成部分。传统的DTV设备通常采用专有的软件...
在Android中,理解文件权限和存储路径是非常重要的,如外部存储(Environment.getExternalStorageDirectory())和内部存储(getFilesDir())的区别。 Gson解析类是Google提供的一个库,用于将Java对象转换为JSON...
Environment Switcher is a tool for switching environments in one-click process using the principles of Java annotation, APT, Reflection, and Proguard during the development and testing of Android. ...
以上功能的实现通常涉及Android SDK中的多个类库,如`BitmapFactory`用于处理图片,`SharedPreferences`和`SQLite`数据库用于缓存,`ConnectivityManager`和`WifiManager`用于网络检测,`SimpleDateFormat`和`Date`...
- **概述**:`android.util`包主要涉及系统底层的一些辅助类,如日志记录、时间处理等实用工具。它是Android应用程序中非常重要的组成部分之一。 - **关键类**: - `Log`:用于记录调试信息。 - `Time`:提供时间...