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:org.opendatakit.utilities.ODKFileUtils.java

public static void verifyExternalStorageAvailability() {
    String cardstatus = Environment.getExternalStorageState();
    if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE)
            || cardstatus.equals(Environment.MEDIA_UNMOUNTED)
            || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY)
            || cardstatus.equals(Environment.MEDIA_SHARED)) {
        throw new RuntimeException("ODK reports :: SDCard error: " + Environment.getExternalStorageState());
    }/* w w  w.j a v  a 2s . co  m*/
}

From source file:activity.DetailsActivity.java

/**
 * Opens the document if it is on storage, else downloads it before open it.
 * /*from   w  w w  .  java2 s  .com*/
 * @param item
 *            the document to open
 */
public void openFileInMemory(final Document item) {
    mItem = item;
    MimeTypeMap map = MimeTypeMap.getSingleton();
    final String mime = map.getMimeTypeFromExtension(item.getExtension());
    mSubPath = item.getTitle() + "." + item.getExtension();

    if (mime != null) {
        if (item.isOnMemory() && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                || Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState())) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(Uri.fromFile(
                    new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
                            .getAbsolutePath() + "/" + mSubPath)),
                    mime.toLowerCase(Locale.US));

            startActivity(Intent.createChooser(i, getString(R.string.dialog_choose_app)));

        } else {
            getService().getDownloadTokenizedUrl(item.getList().getCours().getSysCode(),
                    item.getResourceString(), mDwlManagerHandler);
        }

    } else {
        DetailsActivity.this.getService().getDownloadTokenizedUrl(item.getList().getCours().getSysCode(),
                item.getResourceString(), mTokenizedURLHandler);
    }
}

From source file:com.todotxt.todotxttouch.util.Util.java

public static boolean isDeviceReadable() {
    String sdState = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(sdState) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(sdState)) {
        return true;
    } else {/*  ww w  .j  av a 2s.  co m*/
        return false;
    }
}

From source file:org.jinzora.util.DrawableManager.java

private boolean externalStorageAvailable() {
    String state = Environment.getExternalStorageState();
    return (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state));
}

From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {

    super.onPrepareOptionsMenu(menu);

    if (!application.isLoaded())
        return false; // Wallet not loaded just yet

    final Resources res = getResources();
    final String externalStorageState = Environment.getExternalStorageState();

    boolean writable = Environment.MEDIA_MOUNTED.equals(externalStorageState);
    boolean readOnly = Environment.MEDIA_MOUNTED_READ_ONLY.equals(externalStorageState);

    menu.findItem(R.id.wallet_options_exchange_rates)
            .setVisible(res.getBoolean(R.bool.show_exchange_rates_option));
    menu.findItem(R.id.wallet_options_restore_wallet).setEnabled(writable || readOnly);
    menu.findItem(R.id.wallet_options_backup_wallet).setEnabled(writable);
    menu.findItem(R.id.wallet_options_export)
            .setEnabled(writable && txListAdapter != null && !txListAdapter.transactions.isEmpty());

    menu.findItem(R.id.wallet_options_encrypt_keys)
            .setTitle(application.getWallet().isEncrypted() ? R.string.wallet_options_encrypt_keys_change
                    : R.string.wallet_options_encrypt_keys_set);

    return true;/*www  . j  ava  2s.c o  m*/

}

From source file:com.jefftharris.passwdsafe.FileListFragment.java

/** Show the files in the current directory */
private void showFiles() {
    String state = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(state) && !Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        itsDir = null;/* w  w w .j av a2s.co m*/
    } else {
        itsDir = getFileDir();
    }

    LoaderManager lm = getLoaderManager();
    lm.restartLoader(0, null, this);
}

From source file:systems.soapbox.ombuds.client.ui.WalletActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final Resources res = getResources();
    final String externalStorageState = Environment.getExternalStorageState();

    menu.findItem(R.id.wallet_options_restore_wallet)
            .setEnabled(Environment.MEDIA_MOUNTED.equals(externalStorageState)
                    || Environment.MEDIA_MOUNTED_READ_ONLY.equals(externalStorageState));
    menu.findItem(R.id.wallet_options_backup_wallet)
            .setEnabled(Environment.MEDIA_MOUNTED.equals(externalStorageState));
    menu.findItem(R.id.wallet_options_encrypt_keys)
            .setTitle(wallet.isEncrypted() ? R.string.wallet_options_encrypt_keys_change
                    : R.string.wallet_options_encrypt_keys_set);

    return true;//w  w  w. ja  v a  2s.c o m
}

From source file:de.schildbach.wallet.ui.WalletActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final Resources res = getResources();
    final String externalStorageState = Environment.getExternalStorageState();

    menu.findItem(R.id.wallet_options_exchange_rates)
            .setVisible(Constants.ENABLE_EXCHANGE_RATES && res.getBoolean(R.bool.show_exchange_rates_option));
    menu.findItem(R.id.wallet_options_sweep_wallet).setVisible(Constants.ENABLE_SWEEP_WALLET);
    menu.findItem(R.id.wallet_options_restore_wallet)
            .setEnabled(Environment.MEDIA_MOUNTED.equals(externalStorageState)
                    || Environment.MEDIA_MOUNTED_READ_ONLY.equals(externalStorageState));
    menu.findItem(R.id.wallet_options_backup_wallet)
            .setEnabled(Environment.MEDIA_MOUNTED.equals(externalStorageState));
    final MenuItem encryptKeysOption = menu.findItem(R.id.wallet_options_encrypt_keys);
    encryptKeysOption.setTitle(wallet.isEncrypted() ? R.string.wallet_options_encrypt_keys_change
            : R.string.wallet_options_encrypt_keys_set);

    return true;/*  w ww  .  j av a 2  s. c o m*/
}

From source file:com.appassit.common.Utils.java

/**
 * Check whether the SD card is readable
 *//*from www. ja v  a  2 s. com*/
public static boolean isSdcardReadable() {
    final String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state) || Environment.MEDIA_MOUNTED.equals(state)) {
        return true;
    }
    return false;
}

From source file:mx.klozz.xperience.tweaker.fragments.DiskInfo.java

public void loadData() {
    set_part_info("/system", "System", sysname, systotal, sysused, sysfree, sysbar, lsys);
    set_part_info("/data", "Data", dataname, datatotal, dataused, datafree, databar, ldata);
    set_part_info("/cache", "Cache", cachename, cachetotal, cacheused, cachefree, cachebar, lcache);

    final String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        internalsd = mPreferences.getString("int_sd_path",
                Environment.getExternalStorageDirectory().getAbsolutePath());
        set_part_info(internalsd, "SD card 1", sd1name, sd1total, sd1used, sd1free, sd1bar, lsd1);
        Log.d(TAG, "SDCard 1: " + internalsd);
    }/*from   w  ww .j av  a2 s . c o  m*/
    externalsd = mPreferences.getString("ext_sd_path", Helpers.extSD());
    if (!externalsd.equals("")) {
        set_part_info(externalsd, "SD card 2", sd2name, sd2total, sd2used, sd2free, sd2bar, lsd2);
        Log.d(TAG, "SDCard 2: " + externalsd);
    }

}