Reputation: 75
I would like to use the internal storage for my files. I use function getExternalFilesDir() which uses the internal storage only when there is no SD card mounted, otherwise it stores the files to SD card.
Is there a way how to use only internal storage (that which is accessible for user) even when is SD card mounted?
Thanks
Upvotes: 1
Views: 560
Reputation: 711
As per Android Training documentation you can use Internal storage only for
You can use internal storage as follows
File file = new File(context.getFilesDir(), filename); //Creates a new file
Or you can follow this
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
Upvotes: 1
Reputation: 8149
getExternalFilesDir()
will provide external storage path not internal to get internal storage path you have to use this method getFilesDir()
check below code.
File file = new File(ctx.getFilesDir()+"/MyFolder");
file.mkdirs()
Upvotes: 2