android 多个SD卡检测 MountService有对应的接口。查询SD的个数,对应获取名字等信息。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 解决 StorageManager sm = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE); try { String[] paths = (String[]) sm.getClass().getMethod("getVolumePaths", null).invoke(sm, null); for(int i = 0; i < paths.length; i++) { Log.i("iii", paths[i]); String status = (String) sm.getClass().getMethod("getVolumeState", String.class).invoke(sm, paths[i]); if(status.equals(android.os.Environment.MEDIA_MOUNTED)) { String txt = "测试成功.txt"; String sPath = paths[i] + File.separator + txt; File file = new File(sPath); if(file.exists()) { file.delete(); } try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } 给力 自己再整理优化一下代码 放到GITHUB去~ android检测wifi和3g状态失败,下面是代码,求大神帮忙看下! 请教:如何计算PCM的帧数 求助,如何实现 微博 “分享” 信息 MediaRecord如何实现mp3编码? 熟ListView的兄弟过来帮帮忙 为了开发有2000预算,该买真机还是开发板? setBackgroundColor将canon.draw画点、线覆盖了 Android图片360全景旋转 怎么用代ma开启强制GPU渲染? android studio安装后出现的问题 设置surfaceview大小后显示视频上边黑边下边灰边 android 设置背景 求救
StorageManager sm = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE);
try
{
String[] paths = (String[]) sm.getClass().getMethod("getVolumePaths", null).invoke(sm, null);
for(int i = 0; i < paths.length; i++)
{
Log.i("iii", paths[i]);
String status = (String) sm.getClass().getMethod("getVolumeState", String.class).invoke(sm, paths[i]);
if(status.equals(android.os.Environment.MEDIA_MOUNTED))
{
String txt = "测试成功.txt";
String sPath = paths[i] + File.separator + txt;
File file = new File(sPath);
if(file.exists())
{
file.delete();
}
try
{
file.createNewFile();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}