Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment.getExternalStorageState() returns false on Virtual Device

I am trying to check whether external storage is available or even I think I made all correct it still says storage is not available.

    private String state;
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.externaldata);
        eWrite = (TextView) findViewById(R.id.tveWrite);
        eRead = (TextView) findViewById(R.id.tveRead);
        enviromentState = Environment.getExternalStorageState();        
if (enviromentState.equals(Environment.MEDIA_MOUNTED)) {
                    // read and write
                    eWrite.setText("you can write");
                    eRead.setText("you can read");
                } else if (enviromentState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
                    // read but cant write
                    eWrite.setText("you cannot write ");
                    eRead.setText("but you can read");
                } else {
                    eWrite.setText("you cannot write");
                    eRead.setText("you canot read");
                }
    }

and I also gave permissions on AndroidManifest.xml

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

here screen shot of my virtual device.

ScreenShot

like image 303
Anar Bayramov Avatar asked Nov 03 '22 06:11

Anar Bayramov


1 Answers

I fixed my problem by expanding SD Card size to 151mb

like image 180
Anar Bayramov Avatar answered Nov 16 '22 10:11

Anar Bayramov