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.
I fixed my problem by expanding SD Card size to 151mb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With