You can write a File class object to disk (in this case, in internal storage) using file streams:
FileInputStream fileInputStream = new FileInputStream(fileToSave); FileOutputStream fileOutputStream = new FileOutputStream(new File(getFilesDir(), "fileToSave.ext")); byte fileContent[] = new byte[(int) fileToSave.length()]; fileInputStream.read(fileContent); fileInputStream.close(); fileOutputStream.write(fileContent); fileOutputStream.close();
Here fileToSave is an object of the class File that needs to be stored in internal storage, "fileToSave.ext" is the name of the saved file.
In the above code, the FileInputStream is received by the original File , then its contents are read into byte[] and this byte array is written to the FileOutputStream .