save file via context - Android android.content

Android examples for android.content:Context

Description

save file via context

Demo Code

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

public class Main{

    public static void save(Context context, String fileName, String content)
            throws IOException {
        FileOutputStream fileOutputStream = context.openFileOutput(
                fileName, Context.MODE_WORLD_READABLE);
        fileOutputStream.write(content.getBytes());
        fileOutputStream.close();//from w w w. j a v  a  2  s . c o m
    }

}

Related Tutorials