为什么在模拟器外部存储在状态删除? [英] Why the external storage on simulator is in state removed?

查看:148
本文介绍了为什么在模拟器外部存储在状态删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建应用程序与存储在外部存储数据打不过的code不上我的模拟器工作,

I am creating App to play with storing data on the external storage, however the code doesn't work on my simulator,

String state = Environment.getExternalStorageState();

返回状态总是删除,以下是我的模拟器配置,其中我设置的大小SD卡作为200M,所以我觉得SD卡应安装在模拟器上。

The returned state is always removed, and below is my simulator configurations of which I set the size of the sd card as 200M, so I think the sd card should be mounted on the simulator.

你知道为什么吗?

推荐答案

我测试过你的初始化。那么,它的工作原理。有几件事情,你可能会想尝试:

I've tested your initialization. Well, it works. Several things you might want to try:


  • 测试与SD卡工作在实际设备上您的应用程序。请问您的code给你正确的状态呢?这将意味着,它不是code,但真正的模拟器。

  • 使用在的onCreate 以下code调用 super.onCreate 之后。它会给你敬酒的表现状态的实际工作路径到外部存储。

  • Test your app on an actual device with working sdcard. Does your code give you the correct state there? That would mean, it's not the code but really the emulator.
  • Use the following code in onCreate after the call to super.onCreate. It'll give you a toast showing state an actuall path to the external storage.

Toast.makeText(
    this,
    Environment.getExternalStorageState() + ", " +
    Environment.getExternalStorageDirectory(),
    Toast.LENGTH_LONG)
    .show();


  • 请确保您的PC为SD卡文件可写空间。根据操作系统这个文件下可以找到你的<家> /安卓/ AVD /<设备名称> .avd / sdcard.img

    这篇关于为什么在模拟器外部存储在状态删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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