views:

29

answers:

1

Hello.

I'm developing an Android application.

I'm wondering if it really necessary to create objects that represent tables from a SQLite database.

I'm implementing insert method and instead using a specific object for a table, maybe I can use a HashMap. This Hashmap will be an argument for that method.

public boolean insertEntry(HashMap entry) {

   ...
   String name = entry.get(Constants.COLUMN_NAME);
   ...
}

What do you think?

+1  A: 

Hi, i used HashMap to present data object in db too, extend HashMap in table data object may be easy to read, example:

public class TableObjectClass extends HashMap<String, String>{

    /* Define column of table object here */
    public static final String KEY_COLUMN_ID         = "id";            /* ID of record */
    public static final String KEY_COLUMN_OTHER      = "version";    /* Define other column */


    /* Define public method to set/get properties of table object, example */
    public String getID(){
        return this.get(KEY_COLUMN_ID);
    }

    public void setID(String strID){
        this.put(KEY_COLUMN_ID, strID);
    }

}
nguyendat
It's a great idea!
VansFannel