不能写在微SD卡在黑莓手机 [英] Cannot Write On Micro SDCard On BlackBerry

查看:230
本文介绍了不能写在微SD卡在黑莓手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以节省微SD卡的一些文件。要检查SD卡的可用性,我使用下面的方法;

I am trying to save some files on micro SDCard. To check the availability of SDCard, I am using the following method;

private boolean isSdCardReady() {
    Enumeration e = FileSystemRegistry.listRoots();

    while (e.hasMoreElements()) {
        if (e.nextElement().toString().equalsIgnoreCase("sdcard/")) {    
            return true;
        }
    }
    return false;
}

即使这个方法返回true,当我试图保存文件,它提供了异常 net.rim.device.api.io.file.FileIOException:文件系统未准备好

这是什么意思?如果SD卡不可用,那么为什么它在 FileSystemRegistry.listRoots上市()

What does this means? If SDCard is not available, then why its listed in FileSystemRegistry.listRoots()?

我怎样才能确保SD卡可用于书写?

How can I make sure that SDCard is available for writing?

我的开发环境:


  • 黑莓JDE Eclipse插件1.5.0

  • 的BlackBerry OS 4.5

  • 黑莓Bold用3G上网卡

推荐答案

解决了问题。我一直在寻找的SD卡,而 rootsEnum.nextElement()的toString(); 返回SD卡。是的,它区分大小写。现在,而不是使用硬codeDSD卡,我已经改变了上面的方法如下;

Solved the problem. I was looking for "sdcard" while rootsEnum.nextElement().toString(); returns "SDCard". Yeah, its case sensitive. Now, instead of using hard-coded "SDCard", I've changed the above method to the following;

private static String getSdCardRootDir() {
    Enumeration rootsEnum = FileSystemRegistry.listRoots();

    while (rootsEnum.hasMoreElements()) {

        String rootDir = rootsEnum.nextElement().toString();

        if (rootDir.equalsIgnoreCase("sdcard/")) {
            return "file:///" + rootDir;
        }
    }

    return null;
}

使用这个,我得到了在其系统中定义的情况下,根目录下。

Using this, I got the root directory in its system defined case.

这篇关于不能写在微SD卡在黑莓手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆