Question: I can't get my head around how to apply the model-view-controller design pattern in an android studio project.

I understand that the view is the .xml layouts and that the activity classes are supposed to be the controllers, but I'm confused about whether general programming logic should be a part of the controller or model.

Can the programming logic related to a particular activity be included within the activity class or should they be separated into two classes? i.e. the activity handling just user input and a second class dealing with the associated programming logic.

Answer: 
hello @Somebloke It is as simple as its name.

1. Android Project Structure means the necessary file that are using to developed an Android Application. for example src file, gen file etc.
	* src: This folder contains the Java source files
	* gen: Generated Java library, this library is for Android internal use only.
	* Res: Here we can store resource files such as pictures, XML files for defining layouts, and so forth. Within this folder there are additional folders such as Drawable, Layout, and Values.
	* AndroidManifest.xml: This is the Android definition file. It contains information about the Android application such as minimum Android version, permission to access Android device capabilities such as INTERNET access permission, ability to use phone permission, etc.

2.MVC :- It is one of the structure that are used developed an Android Application.

* ***Model*** -- The data layer, responsible for managing the business logic and handling network or database API.
* ***View*** --the UI layer — a visualization of the data from the Model.
* ***Controller*** --the logic layer, gets notified of the user’s behavior and updates the Model as needed.[![enter image description here](https://i.stack.imgur.com/J98tr.png)](https://i.stack.imgur.com/J98tr.png)

you can take this one as an example <https://github.com/hkusu/android-mvc-sample>
```html
//Student Model Class
public class Student {
   private String rollNo;
   private String name;

   public String getRollNo() {
      return rollNo;
   }

   public void setRollNo(String rollNo) {
      this.rollNo = rollNo;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }
}

//Student View Class
public class StudentView {

  private TextView name;
  private TextView rollNo;

   public StudentView(View view){
      name=(TextView)view.findViewById(R.id.tv_name);
      rollNo=(TextView)view.findViewById(R.id.tv_roll_no);
   }

   public void setStudentDetails(Student studentModel){
      name.setText(studentModel.getName());
      rollNo.setText(studentModel.getRollNo());
   }
}

//Student Controller Class
public class StudentController {
   private Student model;
   private StudentView view;

   public StudentController(Student model, StudentView view){
      this.model = model;
      this.view = view;
   }

   public void setStudentName(String name){
      model.setName(name);  
   }

   public String getStudentName(){
      return model.getName();  
   }

   public void setStudentRollNo(String rollNo){
      model.setRollNo(rollNo);  
   }

   public String getStudentRollNo(){
      return model.getRollNo();  
   }

   public void updateView(){    
      view.setStudentDetails(model);
   } 
}
```

You can use the MVC pattern as given above.Create objects of all three classes in activity and pass the activity's view(xml file) reference to the StudentView object.Create child views in StudentView class as mentioned in xml file.