一般是:

scard0:指系统内部存储

scard1:指外插的sd卡

也有特例。。

分别获取路径的方法:

package com.main;

import java.lang.reflect.Method;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView; public class MainActivity extends Activity {
TextView tv1;
TextView tv2; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = (TextView) findViewById(R.id.tv1);
tv2 = (TextView) findViewById(R.id.tv2);
String str1 = getPrimaryStoragePath();
String str2 = getSecondaryStoragePath();
tv1.setText(str1);
tv2.setText(str2); } private static final String TAG = "PhoneStatusBarPolicy"; public String getPrimaryStoragePath() {
try {
StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
Method getVolumePathsMethod = StorageManager.class.getMethod(
"getVolumePaths", null);
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, null);
// first element in paths[] is primary storage path
return paths[0];
} catch (Exception e) {
Log.e(TAG, "getPrimaryStoragePath() failed", e);
}
return null;
} public String getSecondaryStoragePath() {
try {
StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
Method getVolumePathsMethod = StorageManager.class.getMethod(
"getVolumePaths", null);
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, null);
// second element in paths[] is secondary storage path
return paths[1];
} catch (Exception e) {
Log.e(TAG, "getSecondaryStoragePath() failed", e);
}
return null;
} public String getStorageState(String path) {
try {
StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
Method getVolumeStateMethod = StorageManager.class.getMethod(
"getVolumeState", new Class[] { String.class });
String state = (String) getVolumeStateMethod.invoke(sm, path);
return state;
} catch (Exception e) {
Log.e(TAG, "getStorageState() failed", e);
}
return null;
}
}
红米手机的效果:

效果:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzQyNTUyNw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

王立平--scard0与scard1分别指的是什么?以及路径获取的更多相关文章

  1. 王立平--TableLayout

    效果: <?xml version="1.0" encoding="utf-8"?>  <TableLayout xmlns:android= ...

  2. 王立平--WebView的缓存机制

    WebView的缓存能够分为页面缓存和数据缓存. 1.   页面缓存是指载入一个网页时的html.JS.CSS等页面或者资源数据. 这些缓存资源是因为浏览器的行为而产生.开发人员仅仅能通过配置HTTP ...

  3. 王立平--poser

    Poser是Metacreations公司推出的一款lemmaId=234814&ss_c=ssc.citiao.link" style="color:rgb(51,102 ...

  4. 王立平--EditPlus激活码

    注冊名:Free User 注冊码:6AC8D-784D8-DDZ95-B8W3A-45TFA

  5. 王立平-Android中对图像进行Base64编码

    // ------------------base64-------------------// public String bitmaptoString(Bitmap bitmap) { // 将B ...

  6. 王立平--android事件监听的3种方式

    第一种通常在activity组件的oncreate事件中直接定义,直接动作. 这样的方式每一个控件都定义一次.通常不方便. Button btn = (Button) findViewById(R.i ...

  7. 王立平-- ContentValues , HashTable , HashMap差别

    ContentValues  :是一种存储机制,key-value 特点:key仅仅能是string类型.value:仅仅能是基本类型,不能是对象. 应用:经常使用语往数据库中插入数据 Content ...

  8. 王立平--eclipse向svnserver上传项目

    1.team-->share project watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzQyNTUyNw==/font/5a6L5L2 ...

  9. 王立平--PopupWindow

    MainActivity.java <span style="font-size:14px;">package com.main; import android.app ...

随机推荐

  1. 关于JSON的简介及取值以及常见面试题

    关于JSON的简介及取值 JSON(JavaScript Object Notation)一种轻量级的数据交互格式 类似于一种数据封装,可以想象为java中student封装类 JSON的数值可以是数 ...

  2. jQuery操作下拉列表以及单选多选框

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. Error C1189: #error: Please use the /MD switch for _AFXDLL builds(转)

    原文转自 https://www.cnblogs.com/zwh0214/p/6048360.html 在VS 2013中编译程序时出现错误: 错误提示1: error C1189: #error : ...

  4. 使用 WideCharToMultiByte Unicode 与 UTF-8互转

    1.简述 最近在发送网络请求时遇到了中文字符乱码的问题,在代码中调试字符正常,用抓包工具抓的包中文字符显示正常,就是发送到服务器就显示乱码了,那就要将客户端和服务器设置统一的编码(UTF-8),而我们 ...

  5. 一个C优先级队列实现

    刚下班没事干,实现了一个简单的优先级队列 #include <stdlib.h>#include <stdio.h> typedef void (*pqueue_setinde ...

  6. 用jsp开发web应用并不是一个高效率的选择

    1.    Android里有办法让js使用java方法像使用自己的方法一样方便,和flex的很相似,flex里面使用java方法就像使用自己的方法一样. 2.    用Flex开发准确的说就是用as ...

  7. ubuntu16下安装telnet和opensshserver

    安装了虚拟机,使用的是ubuntu 16,server版本. 启动后发现没有telnet和ssh,就安装了(netstat -a|grep telnet). apt-get install openb ...

  8. [BZOJ1017][JSOI2008]魔兽地图DotR 树形dp

    1017: [JSOI2008]魔兽地图DotR Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 2597  Solved: 1010[Submit][ ...

  9. Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table【递推】

    A. Maximum in Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  10. Python_Tips[1] -> 利用 Python 的字典实现 Switch 功能

    利用 Python 的字典实现 Switch 功能 Python是没有switch语句的,当遇到需要实现switch语句的功能时,一般可以用if/else进行代替,但是还有一种更加简洁的实现方法,利用 ...