SDカードのディレクトリ・パス

それなりの記述(Environment.getExternalStorageDirectory)でマルチにいけると思ったのだが、国内機種を中心にいろいろある。

SDカードパスまとめ - hidecheckの日記 

環境変数に持ってるらしい。

System.getenv("EXTERNAL_STORAGE_ALL")で取得結果です。
/mnt/sdcard:/mnt/usbdisk:/mnt/ext_card
System.getenv("EXTERNAL_ALT_STORAGE");
・EXTERNAL_STORAGE
・SECOND_VOLUME_STORAGE
・THIRD_VOLUME_STORAGE
・EXTERNAL_ALT_STORAGE
環境変数についてはSO-03DにはEXTERNAL_STORAGE_ALLというのがあ り、
/mnt/sdcard:/mnt/usbdisk:/mnt/sdcard/external_sd
というのが取れるらしいというのはわかりました。

Xperia acro HDのSDカードのパスを取得する方法 - Google グループ 

どうも国産中心らしいが。

F-05D      /mnt/sdcard/external_sd/
IS12S       /mnt/ext_card/
ISW11M    /mnt/sdcard-ext/
N-04D      /mnt/sdcard/external_sd/
T-01D      /mnt/sdcard/external_sd/
SC-02C    /mnt/sdcard/external_sd/
SO-03D    /mnt/sdcard/external_sd/
ISW11F     /mnt/sdcard/external_sd/
F-08D       /mnt/sdcard/external_sd/
SC-02B     /mnt/sdcard/external_sd/
ISW11SC    /mnt/sdcard/external_sd/
SC-03D     /mnt/sdcard/external_sd/
N50GT_A    /mnt/storage/sdcard/

パス別に並べるとこれくらいか。

/mnt/sdcard/external_sd/
/mnt/ext_card/
/mnt/sdcard-ext/
/mnt/storage/sdcard/

環境変数名が端末によって違うので困る。

こんな雰囲気だったり。

/sdcard       → 内蔵ストレージ
/sdcard/external_sd → SDカード(外部ストレージ)

スマホ初心者注意!Androidのバックアップに潜む罠 | ガジェット速報 

実際のSDカードのパスを調べるのはどうすべきか。

android - Find an external SD card location - Stack Overflow 

簡単に以下でチェックしながらやってみますか。

 File.exists(), File.isDirectory(), and File.canWrite().

機種別にSDカード内ディレクトリもOSとしては認識している。

Environment | Android Developers 

ダウンロードディレクトリに対しては以下で取得できる?

File pathExternalPublicDir = 
    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
// Downloadフォルダーのパス
String dir = pathExternalPublicDir.getPath();

Android:フォルダパスを動的に取得 - りりーの幸せ日記 

マニュアルによいコードがある。

public static File getExternalStoragePublicDirectory (String type)
Since: API Level 8
特別のタイプのファイルを置くためにトップレベルの公の外部記憶装置ディレクトリーを得てください。
これはユーザが典型的には自分のファイルを置き管理する場所です。したがって、あなたは、それらのファイルを消さないか自分の構成の邪魔にならないことを保証するために、ここで何を置くかに注意するべきです。
Here is an example of typical code to manipulate a picture on the public external storage:
void createExternalStoragePublicPicture() {
    // Create a path where we will place our picture in the user's
    // public pictures directory.  Note that you should be careful about
    // what you place here, since the user often manages these files.  For
    // pictures and other media owned by the application, consider
    // Context.getExternalMediaDir().
    // 私たちがユーザの公開画像ディレクトリーに写真を置くところで、パスを作成してください。
    // ユーザがこれらのファイルをしばしば管理するので、ここで何を置くかに注意するべきであることに注意してください。
    //適用によって所有された絵および他のメディアについては、Context.getExternalMediaDir()を考慮してください。

    File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");

    try {
        // Make sure the Pictures directory exists.
        path.mkdirs();

        // Very simple code to copy a picture from the application's
        // resource into the external file.  Note that this code does
        // no error checking, and assumes the picture is small (does not
        // try to copy it in chunks).  Note that if external storage is
        // not currently mounted this will silently fail.
        InputStream is = getResources().openRawResource(R.drawable.balloons);
        OutputStream os = new FileOutputStream(file);
        byte[] data = new byte[is.available()];
        is.read(data);
        os.write(data);
        is.close();
        os.close();

        // Tell the media scanner about the new file so that it is
        // immediately available to the user.
        MediaScannerConnection.scanFile(this,
                new String[] { file.toString() }, null,
                new MediaScannerConnection.OnScanCompletedListener() {
            public void onScanCompleted(String path, Uri uri) {
                Log.i("ExternalStorage", "Scanned " + path + ":");
                Log.i("ExternalStorage", "-> uri=" + uri);
            }
        });
    } catch (IOException e) {
        // Unable to create file, likely because external storage is
        // not currently mounted.
        Log.w("ExternalStorage", "Error writing " + file, e);
    }
}

void deleteExternalStoragePublicPicture() {
    // Create a path where we will place our picture in the user's
    // public pictures directory and delete the file.  If external
    // storage is not currently mounted this will fail.
    File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");
    file.delete();
}

boolean hasExternalStoragePublicPicture() {
    // Create a path where we will place our picture in the user's
    // public pictures directory and check if the file exists.  If
    // external storage is not currently mounted this will think the
    // picture doesn't exist.
    File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");
    return file.exists();
}

Environment | Android Developers 

このサンプリのように保存した画像はほかアプリから使えるようにに反映させておくとよい。

MediaScannerConnectionを使って画像をギャラリーに反映させる « Tech Booster 

けど、最終的には、環境変数を元に書き込みチャレンジするしか、という。

SDカード 内部と外部

内部SDカードと外部SDカードを持つ機種もある。
GALAXY S2の場合は、本体ストレージの一部を内部SDカードして扱います。
内部SDカードは、“/sdcard”になります。
また、通常のmicroSDカードを外部SDカードとして扱います。
外部SDカードは、“/sdcard/external_sd”になります。

spモードメールの絵文字は、デフォルトでは内部SDカードの“Download”フォルダに保存されます。
この“Download”フォルダの下にアプリのマイファイルで種類毎にフィルダを作成し、
絵文字を保存(移動)すればいいと思います。

価格.com - 『SDカードとマイファイル』 サムスン GALAXY S II LTE SC-03D docomo [Dark Gray] のクチコミ掲示板 

内部SDカードを優先にしたほうがSPモードアプリとの連携がよい。