Example usage for android.os Environment MEDIA_MOUNTED_READ_ONLY

List of usage examples for android.os Environment MEDIA_MOUNTED_READ_ONLY

Introduction

In this page you can find the example usage for android.os Environment MEDIA_MOUNTED_READ_ONLY.

Prototype

String MEDIA_MOUNTED_READ_ONLY

To view the source code for android.os Environment MEDIA_MOUNTED_READ_ONLY.

Click Source Link

Document

Storage state if the media is present and mounted at its mount point with read-only access.

Usage

From source file:com.moonpi.swiftnotes.MainActivity.java

public boolean isExternalStorageReadable() {
    String state = Environment.getExternalStorageState();

    return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
}

From source file:org.smilec.smile.student.CourseList.java

private void takepicture() {

    chkimg = 1;/*from   www  .j  a va 2s  .c om*/
    TakenImage = false;

    // check if external storage exist
    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;
    }

    if (mExternalStorageAvailable == false || mExternalStorageWriteable == false) {
        showToast("We cannot take picture. Please check if the external storage available or writeable.");
        return;
    }

    // -----------------------------------------------------------------
    // Start Built-in Camera Activity
    // -----------------------------------------------------------------
    // define the file-name to save photo taken by Camera activity
    String img_filename = "new-photo-name.jpg";
    // create parameters for Intent with filename
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, img_filename);
    values.put(MediaStore.Images.Media.DESCRIPTION, "Image capture by camera");
    // imageUri is the current activity attribute, define and save it for
    // later usage (also in onSaveInstanceState)
    imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    // imageUri =
    // getContentResolver().insert(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
    // values);

    // create new Intent
    camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    camera_intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    startActivityForResult(camera_intent, IMAGECAPTURE_OK);

}

From source file:com.jtschohl.androidfirewall.MainActivity.java

public void exportRules() {
    Intent intent = new Intent();
    intent.setClass(this, ExportRulesDialog.class);
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        startActivityForResult(intent, EXPORT_RULES_REQUEST);
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        Toast.makeText(this, R.string.no_storage, Toast.LENGTH_LONG).show();
    } else {/*from w  ww. ja  va2s  .  co m*/
        // 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
        Toast.makeText(this, R.string.no_storage, Toast.LENGTH_LONG).show();
    }

}

From source file:com.ehdev.chronos.lib.Chronos.java

public static boolean getCardWriteStatus() {

    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        return true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        return false;
    } else {//w  ww. j  av  a  2  s .c om
        // 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
        return false;
    }
}

From source file:com.ehdev.chronos.lib.Chronos.java

public static boolean getCardReadStatus() {

    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        return true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        return true;
    } else {// w w w . j a v a  2 s  .  c  o m
        // 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
        return false;
    }
}

From source file:com.f8full.casserolesencours.CasserolesEnCoursActivity.java

private File getSDCardFile(boolean checkWriteAccess) {
    boolean externalStorageAvailable = false;
    boolean externalStorageWriteable = false;
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        externalStorageAvailable = externalStorageWriteable = true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        externalStorageAvailable = true;
        externalStorageWriteable = false;
    } else {//from w  ww .  ja  v  a  2s .  co  m
        // 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
        externalStorageAvailable = externalStorageWriteable = false;
    }

    if (externalStorageAvailable == false)
        return null;
    else if (checkWriteAccess && !externalStorageWriteable)
        return null;
    else
        return getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);

}

From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java

private void initStorageSettings() {
    T.UI();//  w w w . ja v  a  2s  .  c o m
    if (IOUtils.shouldCheckExternalStorageAvailable()) {
        String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state)) {
            mExternalStorageAvailable = mExternalStorageWriteable = true;
            if (mQueue.size() > 0)
                mDownloaderHandler.post(mQueueProcessor);
        } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
            mExternalStorageAvailable = true;
            mExternalStorageWriteable = false;
            if (mQueue.size() > 0)
                mDownloaderHandler.post(mQueueProcessor);
        } else {
            mExternalStorageAvailable = mExternalStorageWriteable = false;
        }
    } else {
        mExternalStorageAvailable = mExternalStorageWriteable = true;
        if (mQueue.size() > 0)
            mDownloaderHandler.post(mQueueProcessor);
    }
}

From source file:com.jtschohl.androidfirewall.MainActivity.java

/**
 * get error reports/* ww w.  j a  va  2  s  . c  om*/
 */

private void getReports() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        Toast.makeText(MainActivity.this, R.string.generate_reports, Toast.LENGTH_SHORT).show();
        getInterfaceInfo();
        Log.d(TAG, "Able to read/write to external storage while running reports");
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        Toast.makeText(this, R.string.no_storage, Toast.LENGTH_LONG).show();
        Log.d(TAG, "Read only access to external storage while trying to run reports");
    } 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
        Toast.makeText(this, R.string.no_storage, Toast.LENGTH_LONG).show();
        Log.d(TAG, "Something is wrong with access to external storage while trying to run reports");
    }
}