Files structure in MVVM (Android)

18,074

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 enter image description here

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.

Share:
18,074

Related videos on Youtube

Jakub Kwiatek
Author by

Jakub Kwiatek

Updated on August 30, 2020

Comments

  • Jakub Kwiatek
    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
    Pat Lee over 3 years
    That's the first android project structure that actually makes sense to me... Thank you!