Tool Tool - 11 months ago 51
Android Question

Android: do we have to manually create model classes?

I'm creating a model class, let's say it's called "History" that will interact with a SQLite Database.

Do we always have to manually create getters/setters/fields for the model class? Aren't there any auto-generators for this?

Example of a model class:

package com.example.fileexplorermanager;

public class History {

//private variables
int _id;
String _file_name;
String _full_path;
String _file_type;

// Empty constructor
public History(){

// constructor
public History(int id, String _name, String _full_path, String _file_type){
this._id = id;
this._file_name = _name;
this._full_path = _full_path;
this._file_type = _file_type;


// getting ID
public int getID(){
return this._id;

// setting id
public void setID(int id){
this._id = id;

public String getFileName(){
return this._file_name;

public void setFileName(String file_name){
this._file_name = file_name;

public String getFullPath(){
return this._full_path;

public void setFullPath(String full_path){
this._full_path = full_path;

public String getFileType(){
return this._file_type;

public void setFileType(String file_type){
this._file_type = file_type;


Answer Source

If you use Eclipse: Source -> Generate Getters and Setters...