java - SQLite insert function/method too many parameter arguments, how to refactor? -


shown here method inserting values columns of sqlite database. have never worked database many columns before. , there on 15 tables in database. did not design database, else did.

how refactor android method if possible make better or less verbose, looks can't use collections object arraylist because of arguments not 1 type, there multiple types string, float, , int.

so require making custom java function, not worth effort. , there 15 different tables require 15 custom objects.

some of general knowledge suggest many arguments in method more 4 or 5. not sure why common accepted way of thinking. if true java method needs haircut real bad. or worse enema.

any ideas?

  public void insertnewrowinspectionplan(int testoneinput, string testtwoinput,  int testthreeinput, float testfourinput, int testfiveinput, int testsixinput,  int testseveninput,  int testeightinput, int testnineinput, float testteninput,  int testeleveninput, string testtwelveinput){                   contentvalues contentvalues = new contentvalues();                   contentvalues.put(column_1, testoneinput);                   contentvalues.put(column_2, testtwoinput);                   contentvalues.put(column_3, testtheeinput);                   contentvalues.put(column_4, testfourinput);                   contentvalues.put(column_5, testfiveinput);                   contentvalues.put(column_6, testsixinput);                   contentvalues.put(column_7, testseveninput);                   contentvalues.put(column_8, testeightinput);                   contentvalues.put(column_9, testnineinput);                   contentvalues.put(column_10, testteninput);                   contentvalues.put(column_11, testeleveninput);                   contentvalues.put(column_12, testtwelveinput);    sqlitedatabase.insert(inspection_plan_transaction, null, contentvalues);        } 

create class test set methods dont have pass parameter in function can pas direct refrence variable of class

example:           public class propertiescontacts {        int _id;     string _title;     string _description ;      public int getid(){         return this._id;     }       public void setid(int id){         this._id = id;     }       public string gettitle(){         return this._title;     }       public void settitle(string title){         this._title = title;     }        public string getdescription (){         return this._description ;     }       public void setdescription (string description ){         this._description  = description ;     }   }    set properties value in activity  propertiescontacts  obj=new propertiescontacts (); obj._id=1; obj._title ="amit"; obj._description ="test"; insertnewrowinspectionplan(obj); hope understan  

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -