To insert 7 values ββin one column, you can use a comma separator like this
where Total_Score_P1 is a string array
// string array
String[] Total_Score = new String[] { p1e1,p1e2,p1e3,p1e4,p1e5,p1e6 }; // Convderting it into a single string String result_ScoreP1 = ("" + Arrays.asList(Total_Score_P1)). replaceAll("(^.|.$)", " ").replace(", ", " , " );
result_ScoreP1 will be
// output this
result_ScoreP1 = "p1e1,p1e2,p1e3,p1e4,p1e5,p1e6";
insert it as a single row into the database and when you extract it again break up the parts, for example
// list of string arrays
// request started
public ArrayList<String> rulTable(String id) { // TODO Auto-generated method stub ArrayList<String> Ruleob = new ArrayList<String>(); Cursor c_rule; try { c_rule = db.query(NameTable, new String[]{ columns1 }, Rule_COurseID + "=" + id , null, null, null, null, null); c_rule.moveToFirst(); // if there is data available after the cursor pointer, add // it to the ArrayList that will be returned by the method. if (!c_rule.isAfterLast()) { do { Ruleob.add(c_rule.getString(0)); } while (c_rule.moveToNext()); } // let java know that you are through with the cursor. c_rule.close(); } catch(Exception e) { } return Ruleob; } //list to get elements ArrayList<String> ListOne = new ArrayList<String>(); ArrayList<String> row ; try{ // received values row = db.TheTable(id); String r1 = row .get(0); } catch(Exception e) { } StringTokenizer st2 = new StringTokenizer(r1, "||"); while(st2.hasMoreTokens()) { String Desc = st2.nextToken(); System.out.println(Desc+ "\t" ); ListOne.add(Desc); // }
Avi Kumar Manku
source share