Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import java.io.FileOutputStream;

public class Main {
    /**
     * Write content to file fileName in internal storage
     * @param context  : context.
     * @param fileName : file name.
     * @param content  : content to back up.
     */
    public static void saveFileToInternalStorage(Context context, String fileName, String content) {
        FileOutputStream outputStream;
        try {
            outputStream = context.openFileOutput(fileName, Context.MODE_PRIVATE);
            outputStream.write(content.getBytes());
            outputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}