I have the seemingly simple plan to write a JSON file to internal storage while obeying the MVVM architecture. Unfortunately, almost all the focus on StackOverflow, tutorials and the official documentation seems to be on external storage or databases. The rest ignores MVVM or is generally outdated.
After a lot of experimentation where somehow filesDir was null, the filesystem was declared as read-only, and I was in a state of general confusion, I settled on a solution which you find as answer below.
Problem
I can't decide if my solution below is reasonable or if it has any major drawbacks or violations of MVVM I overlooked. I am absolutely missing some kind of authoritative guide for such a basic task, so I tried to create one here. Please help me make this an up-to-date, industry standard guide for beginners like me!