Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Save a file on Internal storage in Android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 753
    Comment on it

    There are two types of storage in Android device, one is external storage and another is internal storage. You should be aware that the file you try to store in internal storage of Android device will gets completely removed if you uninstall the application. However this is not the case with saving files on external storage.

    **Below is the code to store a file to internal storage of an Android device.**

    String fileName = "File";
    String content = "Save file on internal storage";
    FileOutputStream outputStream = null;
    
    try {
        outputStream = openFileOutput(fileName, Context.MODE_PRIVATE);
        outputStream.write(content.getBytes());
        outputStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    This code will create a file named "File" with data in it "Save file on internal storage" in internal store inside **"/data/data/[package name]/files"**. All the files you will find inside files directory. In the above code the **MODE_PRIVATE** will makes the files more secure by making it inaccessible to other app.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: