草庐IT

getExternalStorageState

全部标签

android - Environment.getExternalStorageState() 在虚拟设备上返回 false

我正在尝试检查外部存储是否可用,甚至我认为我已全部正确它仍然说存储不可用。privateStringstate;protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.externaldata);eWrite=(TextView)findViewById(R.id.tveWrite);eRead=(TextView)findViewById(R.id.tveRead);enviromentState=Environment.get

检查外部存储状态时 Android logcat 错误 "getExternalStorageState/mnt/sdcard"

在我的GalaxyTab10.1上,我在检查外部存储状态时遇到奇怪的logcat错误:Environment.getExternalStorageState();Logcat说:03-1014:13:22.700:E/Environment(32754):getExternalStorageState/mnt/sdcard在Google上搜索时并没有真正找到有用的东西。我发现的唯一信息可能与文件系统有关。这个错误可以修复吗?我在这个小型测试项目中使用了API级别11。编辑:澄清一下...getExternalStorageState()有效并返回MEDIA_MOUNTED,我只是对这个

android - 试图模拟 Environment.getExternalStorageState

几个小时以来,我一直在努力弄清楚如何在对我的Android应用程序进行单元测试时模拟对Environment.getExternalStorateState()的调用。我已经能够模拟SystemServices、Providers和Services,但我不知道如何模拟这个调用,因为它不是对我上下文中提供的东西的调用,而是对操作系统环境中的东西的调用。如有帮助,将不胜感激。 最佳答案 你可以围绕这个调用编写helper并在之后轻松模拟它(很抱歉在类名中有helper部分):publicclassEnvironmentHelper{pu