title: Creating data model class for database handling
body: <p>I was just starting to work on an database application when I realized I should implement <code>MVC</code> pattern as the application is quite complex and involves a number of database operations.<br>
  In regards to this, I have decided to create a separate <code>model class</code> for handling database operations. This class will have all methods which will return me the data after executing Sqlite command(Select for instance) <strong>OR</strong> will simply execute the SQLite command(Delete for instance). But what I want is to separate this class from <code>Database Adapter</code> class, where I open, create and close my database.<br>
  Let me put my concept into code :  </p>
  
  <pre><code>public class DataModel
  {
  /*
  
  Private members
  
  */
  
  // Method to Select data from Student table
  public ArrayList&lt;String&gt; FetchStudents (parameter 1)
  {
  private ArrayList&lt;String&gt; arrStudent;
  
  
  DatabaseAdapter objDB= new DatabaseAdapter();
  objDB.open();  
  /*
  Some code
  */
  objDB.close();
  
  
  return arrStudent
  }
  
  //Method to delete record from Student table
  public DeleteStudent(parameter 1)
  {
  DatabaseAdapter objDB= new DatabaseAdapter();
  objDB.open();
  //Some code
  objDB.close();
  }
  
  /*
  
  Rest of methods
  
  */
  }  
  </code></pre>
  
  <p>//DatabaseAdapterClass  </p>
  
  <pre><code>private static class DatabaseHelper extends SQLiteOpenHelper {
  DatabaseHelper(Context context) {
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }
  /**
  * onCreate method is called for the 1st time when database doesn't exists.
  */
  @Override
  public void onCreate(SQLiteDatabase db) {
  Log.i(TAG, "Creating DataBase: " + CREATE_STUDENT_TABLE);
  db.execSQL(CREATE_STUDENT_TABLE);
  }
  /**
  * onUpgrade method is called when database version changes.
  */
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                          + newVersion);
  }
  }  
  </code></pre>
  
  <p><strong>Question</strong>:<br>
  What I want to ask is this the correct approach of implementation? Is it fine if create separate class for <em>database methods</em>? What limitations or issues you guys think might trouble me later on? Also, is there a better way to implement the above concept?  </p>
  
  <p>Thanks<br>
  Stone</p>