- 浏览: 187383 次
- 性别:
- 来自: 郑州
最新评论
-
gaoyansansheng:
,第一个方法是全角符转半角符吧?
Android TextView自动换行文字排版参差不齐的原因 -
wyyl1:
牛逼!用第一个方法就行了,简单!
Android TextView自动换行文字排版参差不齐的原因 -
XuNiu:
好内容虽然过了这么久了,但是一定要赞一下
android 命名规范
1、讲述 Environment 类
Environment 是一个提供访问环境变量的类。
Environment 包含常量:
MEDIA_BAD_REMOVAL
解释:返回getExternalStorageState() ,表明SDCard 被卸载前己被移除
MEDIA_UNMOUNTABLE
MEDIA_CHECKING
解释:返回getExternalStorageState() ,表明对象正在磁盘检查。
MEDIA_MOUNTED
解释:返回getExternalStorageState() ,表明对象是否存在并具有读/写权限
MEDIA_MOUNTED_READ_ONLY
解释:返回getExternalStorageState() ,表明对象权限为只读
MEDIA_NOFS
解释:返回getExternalStorageState() ,表明对象为空白或正在使用不受支持的文件系统。
MEDIA_REMOVED
解释:返回getExternalStorageState() ,如果不存在 SDCard 返回
MEDIA_SHARED
解释:返回getExternalStorageState() ,如果 SDCard 未安装 ,并通过 USB 大容量存储共享 返回
解释:返回getExternalStorageState() ,返回 SDCard 不可被安装 如果 SDCard 是存在但不可以被安装
MEDIA_UNMOUNTED
解释:返回getExternalStorageState() ,返回 SDCard 已卸掉如果 SDCard 是存在但是没有被安装
Environment 常用方法:
方法:getDataDirectory()
解释:返回 File ,获取 Android 数据目录。
方法:getDownloadCacheDirectory()
解释:返回 File ,获取 Android 下载/缓存内容目录。
方法:getExternalStorageDirectory()
解释:返回 File ,获取外部存储目录即 SDCard
方法:getExternalStoragePublicDirectory(String type)
解释:返回 File ,取一个高端的公用的外部存储器目录来摆放某些类型的文件
方法:getExternalStorageState()
解释:返回 File ,获取外部存储设备的当前状态
方法:getRootDirectory()
解释:返回 File ,获取 Android 的根目录
2、讲述 StatFs 类
StatFs 一个模拟linux的df命令的一个类,获得SD卡和手机内存的使用情况
StatFs 常用方法:
getAvailableBlocks()
解释:返回 Int ,获取当前可用的存储空间
getBlockCount()
解释:返回 Int ,获取该区域可用的文件系统数
getBlockSize()
解释:返回 Int ,大小,以字节为单位,一个文件系统
getFreeBlocks()
解释:返回 Int ,该块区域剩余的空间
restat(String path)
解释:执行一个由该对象所引用的文件系统
在没有挂载前存储媒体已经被移除。 |
||
正在检查存储媒体。 |
||
存储媒体已经挂载,并且挂载点可读/写。 |
||
存储媒体已经挂载,挂载点只读。 |
||
存储媒体是空白或是不支持的文件系统。 |
||
存储媒体被移除。 |
||
存储媒体正在通过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 = new File(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. InputStream is = getResources().openRawResource(R.drawable.balloons); OutputStream os = new FileOutputStream(file); byte[] data = new byte[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, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void 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 = new File(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 = new File(path, "DemoPicture.jpg"); return file.exists(); }
Parameters
The type of storage directory to return. Should be one of DIRECTORY_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()
.
发表评论
-
android textview 特出显示
2013-04-22 19:40 1604在xml文件中使用android:textStyle=&qu ... -
反编译apk
2013-02-27 10:42 934工具下载:需用到dex2ja ... -
Android 通过字符串来获取R下面资源的ID 值
2013-01-30 14:33 1166方法一: try{ Field field= ... -
android禁止锁屏保持常亮 .
2012-12-26 11:12 4682在播放video的时候在mediaplayer mMedia ... -
Eclipse开发Android的配置(包括ADT安装,SDK配置)
2012-12-08 12:35 17261. 下载Android SDK htt ... -
android 命名规范
2012-12-03 19:16 4093一、Android编码规范 1.java代码中不出现中文 ... -
div+css命名规范 嫁接android xml命名
2012-12-03 19:13 1049CSS命名规则 头:header 内容:co ... -
android 之 Task Activity .
2012-11-27 20:55 2555首先task包含一个或多个activity,它是安排在一个堆栈 ... -
最本质的多线程:hanlder和message机制:
2012-11-27 19:58 1659Android多线程 作者:陈 ... -
android之多线程工作(一)AsyncTask .
2012-11-27 19:35 1290本文章主要讲解下AsyncTa ... -
Android 重要包描述
2012-10-25 13:21 937在Android中,各种包写成android.* 的方式,重要 ... -
android.os.NetworkOnMainThreadException 异常处理
2012-10-20 15:12 1050android.os.NetworkOnMainThreadE ... -
android textview属性
2012-08-24 16:10 813android:autoLink设置是否当 ... -
GestureDetector.OnDoubleTapListener 和 GestureDetector.OnGestureListener
2012-07-20 21:30 1962android.view.GestureDetector. ... -
Android Google Map API的使用(一)
2012-07-17 20:49 1065Android中定义了一个名为com.google.andro ... -
Android中Context简介
2012-07-15 19:20 10323Context字面意思是上下文,位于framework pac ... -
XmlPullParser
2012-07-06 16:14 10281在Android中,如果要想完成PULL解析处理需要 o ... -
DocumentBuilder API 官方翻译(翻译有错的地方请多指正)
2012-07-04 12:27 1209public abstract class Document ... -
Android开发如何去除标题栏title
2012-07-02 18:18 752Android开发如何去除标题栏title 去除标题栏tit ... -
Android 获取存储卡路径和空间使用情况
2012-07-01 16:55 5665/** 获取存储卡路径 */ File sdc ...
相关推荐
Beginning with the basics, this book provides an outline of the steps necessary to set up an Android development and testing environment. An overview of Android Studio is included covering areas such ...
This book covers Android app design fundamentals in Android Studio using Java programming language. The author assumes you have no experience in app development. The book starts with the installation ...
Android Studio is an intuitive, feature-rich, and extremely forgiving Integrated Development Environment (IDE). This IDE is more productive and easier to use for your Android app creations than ...
A short introduction to the Android platform and its development environment Using the essential parts of Android applications, such as user interface components, notifications, and resources Storing ...
Set up a development environment to build Android Wear apps using Android Studio Master the Android Wear SDK and APIs Understand the UI patterns and UX principles to build Android Wear apps Work with ...
Setting Up Your Android Development Environment Chapter 4. Introducing the Android Software Development Platform Chapter 5. Android Framework Overview Chapter 6. Screen Layout Design: Views and ...
Environment Setup Chapter 3. Architecture Chapter 4. Application Components Chapter 5. Hello World Example Chapter 6. Resources Organizing & Accessing Chapter 7. ACCESSING RESOURCES IN CODE Chapter 8...
public class DecodeActivity extends Activity implements SurfaceHolder.Callback { // private static final String strVideo = // Environment.getExternalStorageDirectory() + "/test/xx.avi"; // ...
安卓手机开发的环境配置,很经典,对初学者很有用,
----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...
android_environment5android_environment5
Initially covering the threats, risks, and vulnerabilities in software and in the Android environment, this book will then dig deeper, exploring different types of authentication methods that can be ...
To compile this widget from source code you will need a functional Android development environment. The only dependency is the Android V4 App Compatibility library, which is included here as a stat
Introduces Android Open Accessory and shows how to set up the hardware and development environment Explains how to code both Android and Arduino elements of an accessory Features four complete ...
You will discover how to manage your Android testing environment using Android emulators, deep dive into how adb and the emulator can super charge your testing automation, and also test user ...
First, Dutson guides you through establishing a highly efficient development environment and workflow, and testing your app to ensure that your code works just as you expect. Then, he walks through ...
You'll be walked through the process of installing and configuring Android on your BeagleBone Black, as well as preparing your PC development environment to create Android applications that directly ...
He explores SQLite in detail, illuminates Android’s APIs for database interaction, and shares modern best practices for working with databases in the Android environment. Through a complete case ...
Offering an open development environment, Android represents an exciting new opportunity to write innovative applications for mobile devices. This book provides you with a hands-on guide to building ...