本帖最后由 yiyaaixuexi 于 2012-01-04 10:09:42 编辑

解决方案 »

  1.   

    如果bytesAvailable > 1048576; megAvailable >= 1
    如果bytesAvailable < 1048576 megAvailable  = 0
    应该转成浮点计算吧
      

  2.   

    首先无论你是不是有sd卡都会,你的判断条件得到的都是挂载sdcard;这个就已经不对了
    所以可以猜测到你的手机应该可能还有一个虚拟的外置存储
    你可以用这段代码试试:File storageFile = android.os.Environment.getExternalStorageDirectory().getAbsoluteFile();
            Debug.log(Tag, "getCurrentAllMountedStoreDisk:storageFile==" + storageFile, FlagDebug);
            int count = 0;
            try {
                File CanonicalFile = storageFile.getCanonicalFile();
                File external = CanonicalFile.getParentFile();
                Debug.log(Tag, "getCurrentAllMountedStoreDisk:CanonicalFile,external==" + CanonicalFile+","+external, FlagDebug);
                if (!external.getAbsolutePath().equals(File.separator)) {
                    File[] file = external.listFiles();
                    for (int i = 0; i < file.length; i++) {
                        File tmp = file[i];
                        if (tmp.canRead() && tmp.canWrite() && tmp.isDirectory() && !tmp.isHidden()) {
                            Debug.log(Tag, "getCurrentAllMountedStoreDisk:file:" + tmp.getAbsolutePath(), FlagDebug);
                            ret.add(tmp.getAbsolutePath());
                            count++;
                        }
                    }
                }
            } catch (IOException e) {
                Debug.log(Tag, "initMount()", e, FlagDebug);
            }
    你打印下看是不是有别的目录,sdcard 可能是/mnt/sdcard 你可能还有什么/mnt/flash之类的
    如果有 你在看着区别处理
      

  3.   

    1楼的方法试一下
    另外你的机器是什么机机型,有的把NAND做为/sdcard,外置SD只是其下一个目录而已
      

  4.   

     Boolean sdcardpresent = android.os.Environment.getExternalStorageState().equals   (android.os.Environment.MEDIA_MOUNTED);这个判断SD Card是否存在有什么问题呢?   我现在要做5个分辨率   应对三款手机的   别的手机这个判断都是没问题的  但是在moto 960x540的时候  无论我是否有SD Card  返回的值都是 true  怎么回事?
     
      

  5.   

    其实下面只是判断   SD Card是否已满而已
      

  6.   

    各种厂商可能会对自己的机器做一些特别处理因为android是开源的改来改去也没有关系,所以各家的文件存储可能都有一些区别,会自己在mnt下虚拟一个新目录存储文件,我们自己的产品就是如此 ,而且无论是否sd卡存在,也是一直mounted状态,所以这个机器可能也是那样的情况,我上面的那段代码你修改修改看看mnt下面有什么文件结构,