Question

I have some queries which may be useful to others too. In android 4.0 onwards ,

1)how to check whether external sd card support is there or not ?

2)How to run Mediascan forcefully both internal and external memory ?

3)How to Mediascan only sd card or internal memory?

Was it helpful?

Solution

I'd recommend reading storage options on developer.android.com.

To check external memory is available (taken from developer.android.com):

boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
    // We can read and write the media
    mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    // We can only read the media
    mExternalStorageAvailable = true;
    mExternalStorageWriteable = false;
} else {
    // Something else is wrong. It may be one of many other states, but all we need
    //  to know is we can neither read nor write
    mExternalStorageAvailable = mExternalStorageWriteable = false;
}

To read internal files use context.fileList(); see more here.

Edit

I'm not sure what you want with 2 and 3. You can use mediascan to many things but using it just for using it sounds unproductive. For that I'd recommend @Singularity advice. There is a post here about using mediascan for pdfs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top