How can I save a file in the device memory so that the user cannot access it?
in the first picture, the file is saved to the SD card and read, everything is fine.
What is the exact error message you're seeing when you attempt to write to the file. Include a screenshot if possible.
Are you testing this in the companion or in a compiled app? The behavior of the companion is to always write to the visible storage for debugging purposes. Only compiled apps will be able to write to their app-private folder on the /data partition. Technically, this can still be read if the device is rooted.