Files structure in MVVM (Android)
Solution 1
If you want to go by the book, the current "correct" way to implement MVVM in Android is the Android Architecture Components set of libraries.
Read more about it here, and try this code lab. These will also show you how to name and place your classes.
But in general, you should go with what matches your app best. For smaller apps I would recommend going with M V P folders, while for bigger, more long-term ones tend to work better with folder-per-feature structure.
Solution 2
Additionnaly you may find this resource interesting https://overflow.buffer.com/2016/09/26/android-rethinking-package-structure/ An implementation is visible here https://github.com/SamYStudiO/beaver
Solution 3
Google in it's sample Android Architecture project uses Model(Data) V(views) VM(view-models) file structure
Google sample sunflower app to show architecture components
Probably that's the best approach
Solution 4
I also would like to indicate watching this TUTORIAL. This guy goes well on teaching about the Architecture MVVM and also uses the ROOM Persistence Library. It is worth giving a look at it.
Related videos on Youtube
Jakub Kwiatek
Updated on August 30, 2020Comments
-
Jakub Kwiatek almost 4 years
using MVVM or MVP should i name packages like model, viewmodel, view and put proper classes and interfaces there or is it just a logical structure that should not be visible in classes structure?
-
Pat Lee over 3 yearsThat's the first android project structure that actually makes sense to me... Thank you!