导航:首页 > 操作系统 > android获得sd卡路径

android获得sd卡路径

发布时间:2022-10-03 18:21:52

android中如何获得外置sd卡的路径和手机自身内存的路径

有些没看
懂你
的意思,一般手机能够自己明白SD卡和内置存储的。如果你要设置路径的话。一般会以sdcard1、sdcard2来作为路径。

㈡ 如何获得在Android的内部和外部SD卡路径

首先我要说的是,你的三星手机,和小米手机,不能写为//sdcard//... 这个系统重新封装了,不能用简写。 String mPath = Environment.getExternalStorageDirectory().toString(); 获得路径字符串。 至于其他参数的,都是辅助

㈢ 获取android手机的自带存储路径和sdcard存储路径

android手机获取自带存储来路径和sd卡存储路径的方式是:调用Environment.getExternalStorageDirectory(),返回的存储源目录并不是系统内置的SD卡目录。
1.一部分手机将eMMC存储挂载到
/mnt/external_sd
、/mnt/sdcard2
等节点知,而将外置的SD卡挂载到
Environment.getExternalStorageDirectory()这个结点。
此时,调用Environment.getExternalStorageDirectory(),则返回外置的SD的路径。
2.而另一部分手机直接道将eMMC存储挂载在Environment.getExternalStorageDirectory()这个节点,而将真正的外置SD卡挂载到/mnt/external_sd、/mnt/sdcard2
等节点。
此时,调用Environment.getExternalStorageDirectory(),则返回内置的SD的路径。

㈣ Android SD卡路径问题以及如何获取SDCard 内存详解

较好的方法是通过Environment
来获取路径,最后给出一个例子,教你怎样获取SDCard
的内存,显示出来告诉用户。讲述的内容如下:0202
0、获取sd卡路径。
1、讲述
Environment
类。
2、讲述
StatFs
类。
3、完整例子读取
SDCard
内存
0、获取sd卡路径
方法一:
private
String
folder
=
"/sdcard/DCIM/Camera/"(SD卡上拍照程序的图片存储路径);
//写死绝对路径,不赞成使用方法二:

㈤ 安卓手机sd卡的路径在哪

【手机存储路径】描述方法:

方法一:/storage/sdcard0/所在文件夹名/文件名

方法二:/mnt/sdcard/所在文件夹名/文件名

【扩展SD卡路径】描述方法:

方法一:/storage/sdcard1/所在文件夹名/文件名

方法二:/mnt/sdcard2/所在文件夹名/文件名

有的手机存储支持两类,一个是手机存储,另一个是扩展SD卡(打开你的手机文件管理器,就能看到你的手机支持哪些了)‘

有些手机因为手机存储容量达到16G,32G,甚至更高等等,就不支持扩展SD卡(有指甲盖大小的,需要卡槽存放的小卡)。

拓展资料;

SD存储卡是一种基于半导体快闪记忆器的新一代记忆设备,由于它体积小、数据传输速度快、可热插拔等优良的特性,被广泛地于便携式装置上使用,例如数码相机、个人数码助理(外语缩写PDA)和多媒体播放器等。

SD卡应用于以下的手提数码装置:

数码相机

储存相片及短片

数码摄录机储存相片及短片

个人数码助理(PDA)储存各类资料

手提电话储存相片、铃声、音乐、短片等资料

多媒体播放器

SD卡多用于MP3随身听、数码摄像机、数码相机等,也有用于笔记本电脑上。SD卡在2013年的发展很快,已经开始威胁到CF卡的市场份额了。不过注意的是,在某些产品例如手机上,SD卡和MMC卡是不能兼容的。2013年的SD卡容量由8MB到128GB不等。

参考链接;网络-SD卡

㈥ 如何正确获得Android内外SD卡路径

/**
* 获取手机自身内存路径
*
*/
public static String getPhoneCardPath(){
return Environment.getDataDirectory().getPath();
}
/**
* 获取sd卡路径
* 双sd卡时,根据”设置“里面的数据存储位置选择,获得的是内置sd卡或外置sd卡
* @return
*/
public static String getNormalSDCardPath(){
return Environment.getExternalStorageDirectory().getPath();
}
/**
* 获取sd卡路径
* 双sd卡时,获得的是外置sd卡
* @return
*/
public static String getSDCardPath() {
String cmd = "cat /proc/mounts";
Runtime run = Runtime.getRuntime();// 返回与当前 Java 应用程序相关的运行时对象
BufferedInputStream in=null;
BufferedReader inBr=null;
try {
Process p = run.exec(cmd);// 启动另一个进程来执行命令
in = new BufferedInputStream(p.getInputStream());
inBr = new BufferedReader(new InputStreamReader(in));

String lineStr;
while ((lineStr = inBr.readLine()) != null) {
// 获得命令执行后在控制台的输出信息
Log.i("CommonUtil:getSDCardPath", lineStr);
if (lineStr.contains("sdcard")
&& lineStr.contains(".android_secure")) {
String[] strArray = lineStr.split(" ");
if (strArray != null && strArray.length >= 5) {
String result = strArray[1].replace("/.android_secure",
"");
return result;
}
}
// 检查命令是否执行失败。
if (p.waitFor() != 0 && p.exitValue() == 1) {
// p.exitValue()==0表示正常结束,1:非正常结束
Log.e("CommonUtil:getSDCardPath", "命令执行失败!");
}
}
} catch (Exception e) {
Log.e("CommonUtil:getSDCardPath", e.toString());
//return Environment.getExternalStorageDirectory().getPath();
}finally{
try {
if(in!=null){
in.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if(inBr!=null){
inBr.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return Environment.getExternalStorageDirectory().getPath();
}
//查看所有的sd路径
public String getSDCardPathEx(){
String mount = new String();
try {
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("mount");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
String line;
BufferedReader br = new BufferedReader(isr);
while ((line = br.readLine()) != null) {
if (line.contains("secure")) continue;
if (line.contains("asec")) continue;

if (line.contains("fat")) {
String columns[] = line.split(" ");
if (columns != null && columns.length > 1) {
mount = mount.concat("*" + columns[1] + "\n");
}
} else if (line.contains("fuse")) {
String columns[] = line.split(" ");
if (columns != null && columns.length > 1) {
mount = mount.concat(columns[1] + "\n");
}
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mount;
}
//获取当前路径,可用空间
public static long getAvailableSize(String path){
try{
File base = new File(path);
StatFs stat = new StatFs(base.getPath());
long nAvailableCount = stat.getBlockSize() * ((long) stat.getAvailableBlocks());
return nAvailableCount;
}catch(Exception e){
e.printStackTrace();
}
return 0;
}

㈦ 获取android手机的自带存储路径和sdcard存储路径

android手机获取自带存储路径和sd卡存储路径的方式是:调用Environment.getExternalStorageDirectory(),返回的存储目录并不是系统内置的SD卡目录。
1.一部分手机将eMMC存储挂载到
/mnt/external_sd
、/mnt/sdcard2
等节点,而将外置的SD卡挂载到
Environment.getExternalStorageDirectory()这个结点。
此时,调用Environment.getExternalStorageDirectory(),则返回外置的SD的路径。
2.而另一部分手机直接将eMMC存储挂载在Environment.getExternalStorageDirectory()这个节点,而将真正的外置SD卡挂载到/mnt/external_sd、/mnt/sdcard2
等节点。
此时,调用Environment.getExternalStorageDirectory(),则返回内置的SD的路径。

㈧ android4.0后怎么获取sdcard的路径(包括外置和内置的)

getExternalStorageDirectory()方法在4.0以后只能获取内置SD卡路径
外置SD卡
/**
* 获取外置SD卡路径
* @return 应该就一条记录或空
*/
public List<string> getExtSDCardPath()
{
List<string> lResult = new ArrayList<string>();
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("mount");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
if (line.contains("extSdCard"))
{
String [] arr = line.split(" ");
String path = arr[1];
File file = new File(path);
if (file.isDirectory())
{
lResult.add(path);
}
}
}
isr.close();
} catch (Exception e) {
}
return lResult;
}

List<string> extPaths = getExtSDCardPath();
for (String path : extPaths) {
log.append("外置SD卡路径:" + path + "\r\n");
}

PS别忘记添加权限,内外置SD卡的权限在4.0以后是不一样的

㈨ 如何正确获得Android内外SD卡路径

/** * 获取手机自身内存路径 * */ public static String getPhoneCardPath(){ return Environment.getDataDirectory().getPath(); } /** * 获取sd卡路径 * 双sd卡时,根据”设置“里面的数据存储位置选择,获得的是内置sd卡或外置sd卡 * @return */ public static String getNormalSDCardPath(){ return Environment.getExternalStorageDirectory().getPath(); } /** * 获取sd卡路径 * 双sd卡时,获得的是外置sd卡 * @return */ public static String getSDCardPath() { String cmd = "cat /proc/mounts"; Runtime run = Runtime.getRuntime();// 返回与当前 Java 应用程序相关的运行时对象 BufferedInputStream in=null; BufferedReader inBr=null; try { Process p = run.exec(cmd);// 启动另一个进程来执行命令 in = new BufferedInputStream(p.getInputStream()); inBr = new BufferedReader(new InputStreamReader(in)); String lineStr; while ((lineStr = inBr.readLine()) != null) { // 获得命令执行后在控制台的输出信息 Log.i("CommonUtil:getSDCardPath", lineStr); if (lineStr.contains("sdcard") && lineStr.contains(".android_secure")) { String[] strArray = lineStr.split(" "); if (strArray != null && strArray.length >= 5) { String result = strArray[1].replace("/.android_secure", ""); return result; } } // 检查命令是否执行失败。 if (p.waitFor() != 0 && p.exitValue() == 1) { // p.exitValue()==0表示正常结束,1:非正常结束 Log.e("CommonUtil:getSDCardPath", "命令执行失败!"); } } } catch (Exception e) { Log.e("CommonUtil:getSDCardPath", e.toString()); //return Environment.getExternalStorageDirectory().getPath(); }finally{ try { if(in!=null){ in.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { if(inBr!=null){ inBr.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return Environment.getExternalStorageDirectory().getPath(); } //查看所有的sd路径 public String getSDCardPathEx(){ String mount = new String(); try { Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec("mount"); InputStream is = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(is); String line; BufferedReader br = new BufferedReader(isr); while ((line = br.readLine()) != null) { if (line.contains("secure")) continue; if (line.contains("asec")) continue; if (line.contains("fat")) { String columns[] = line.split(" "); if (columns != null && columns.length > 1) { mount = mount.concat("*" + columns[1] + "\n"); } } else if (line.contains("fuse")) { String columns[] = line.split(" "); if (columns != null && columns.length > 1) { mount = mount.concat(columns[1] + "\n"); } } } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return mount; } //获取当前路径,可用空间 public static long getAvailableSize(String path){ try{ File base = new File(path); StatFs stat = new StatFs(base.getPath()); long nAvailableCount = stat.getBlockSize() * ((long) stat.getAvailableBlocks()); return nAvailableCount; }catch(Exception e){ e.printStackTrace(); } return 0; }

㈩ android怎么获取sd卡的路径

链接电脑USB调试情况下,在电脑上有新的磁盘显示,一个SD的,一个手机的,打开SD的就可以找各文件夹路径

阅读全文

与android获得sd卡路径相关的资料

热点内容
程序员基础架构岗怎么样 浏览:412
有什么好的付费app 浏览:626
java生成6随机数字 浏览:177
汇编语言程序设计教程pdf 浏览:44
我的老公是冥王在哪个app上看 浏览:70
程序员婚前准备 浏览:372
金铲铲之战微信安卓兑换码怎么换 浏览:846
单片机38译码器 浏览:335
思域换压缩机 浏览:183
必应服务器ip地址 浏览:628
魔兽世界服务器怎么连接 浏览:39
什么地方会用到云服务器 浏览:54
pdfarchitect 浏览:676
图片找不到文件夹 浏览:199
看书免费app哪个最好 浏览:630
python服务器怎么安装 浏览:382
程序员新技术 浏览:52
安卓如何在桌面上添加音乐 浏览:141
手机相册加密连接电脑可以看到吗 浏览:894
51单片机怎么写成函数 浏览:322