Java tutorial
//package com.java2s; /* * XPerience Kernel Tweaker - An Android CPU Control application * Copyright (C) 2011-2015 Carlos "Klozz" Jesus <TeamMEX@XDA-Developers> * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ import android.text.TextUtils; import java.io.*; public class Main { public static String extSD() { String externalsd = ""; if (!TextUtils.isEmpty(System.getenv("SECONDARY_STORAGE"))) { final String externalstorage[] = System.getenv("SECONDARY_STORAGE").split(":"); for (final String dirs : externalstorage) { final File dir = new File(dirs); if (dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite()) { externalsd = dirs; break; } } } else { final String supported[] = { "/mnt/extSdCard", "/storage/sdcard1", "/mnt/external_sd" }; for (final String dirs : supported) { final File dir = new File(dirs); if (dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite()) { externalsd = dirs; break; } } } return externalsd; } }