android 数组添加数据,在android中的SQLite数据库中插入数组

要在一列中插入7个值,您可以使用这样的逗号分隔符

其中Total_Score_P1是一个字符串数组

//字符串数组

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将是

//输出

result_ScoreP1 = "p1e1,p1e2,p1e3,p1e4,p1e5,p1e6";

将它作为单个字符串插入数据库中,并在再次检索时将其中的部分删除

//一个字符串数组列表

//查询已解雇

public ArrayListrulTable(String id) { // TODO Auto-generated method stub ArrayListRuleob = new ArrayList(); 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's 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 ArrayListListOne = new ArrayList(); ArrayListrow ; 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); // }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值