How to set openFileOutput mode to MODE_PRIVATE and MODE_APPEND?

Why do I need to choose between MODE_PRIVATE and MODE_APPEND for

 openFileOutput(String name, int mode) 

? How to set both parameters?

+4
source share
1 answer

Just OR two constants:

 openFileOutput(name, MODE_PRIVATE | MODE_APPEND); 

Also MODE_PRIVATE is defined as 0 ( http://developer.android.com/reference/android/content/Context.html#MODE_PRIVATE ), so even omitting it completely from the line above will have the desired effect. I usually just add it with OR for better readability.

+9
source

Source: https://habr.com/ru/post/1489755/


All Articles