Question about saving files in Android.

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 13

Apr 4, 2016, 6:40:25 AM via Website

If I want to write raw data (binary file writing) how do I do that? I assume I need to open a file (or create one if it doesn't exist) with one function, write to the file with another function, and then close the file with yet another function. Please let me know the best way to do this. What file writing functions are available in Android?

  • Forum posts: 13

Apr 4, 2016, 9:46:01 AM via Website

Thanks, but now I have another question. I understand that Environment.getExternalStoragePublicDirectory give you a public folder, and that context.getExternalFilesDir() gets you a folder that's private to the app in question, but what does context.getExternalCacheDir() get you, and what does Environment.getExternalStorageDirectory get you?

  • Forum posts: 266

Apr 4, 2016, 10:37:41 AM via Website

Context.getExternalCacheDir() returns absolute path to application-specific directory on the primary shared/external storage device where the application can place cache files it owns. It's used to save files temporarily.
Environment.getExternalStorageDirectory returns path to external storage, example: "/storage/sdcard0" or "/storage/extSdCard".

Recommended by NextPit