Check blackberry is connected via USB

北城余情 提交于 2019-12-12 20:13:58

问题


I am doing an application which access the SD/Media card to display its images. But when device is connected via USB I cant access the media card. If thats the case, I want to show a message to user asking him to disconnect device form computer.

  1. How can I programatically check that SDCard is accessible or not ?
  2. How can I check whether the device is connected to computer via USB?

Thanks.


回答1:


I am not sure about your second question about checking whether the device filesystem is mounted via USB on a computer, but as for the first question, to check the available filesystems, call FilesystemRegistry.listRoots(), which will return an Enumeration of String objects. If "SDCard/" is in the enumeration, then the SDCard is available.

Some devices can also store images on the device storage as well, which is distinct from the SDCard. In that case, check for "store/" as the filesystem root.



来源:https://stackoverflow.com/questions/9262740/check-blackberry-is-connected-via-usb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!