save To SD Card - Android android.os

Android examples for android.os:Environment

Description

save To SD Card

Demo Code

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Environment;
import java.io.*;

public class Main{
    public static void saveToSDCard(String fileName, String content)
            throws IOException {
        File file = new File(Environment.getExternalStorageDirectory(),
                fileName);/*from  w w  w . ja v  a  2  s .  com*/
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        fileOutputStream.write(content.getBytes());
        fileOutputStream.close();
    }

}

Related Tutorials