我要保存在数据库中平日里,所以我想通过指定int值的每一天储存。即
I want to save weekdays in database, so i thought to store it by assigning int value to each day. i.e
1 - >选 0 - >未选择
1 -> Selected, 0 -> Not Selected.
周一= 0/1
周二= 0/1
。 。 。 。
星期日= 0/1。
但是,这将使7列的 DB 。所以我在想,如果有人可以帮助我,如果我应该将其存储在一个单一的阵列和检索为进一步利用的价值。我正在读的一些例子在互联网上,但没有得到它在一个简单的方法。
But this will make 7 columns in DB. So I was thinking if anyone can help me with this if I should store it in a single array and retrieve the values for further use. I was reading some examples over internet but didn't get it in a easy way.
要插入7个值一列,你可以用逗号分隔符像这样
To insert 7 values in one column you can use comma separator like this
在这里Total_Score_P1是一个字符串数组
where Total_Score_P1 is an 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将
result_ScoreP1 will be
//输出这个
result_ScoreP1 = "p1e1,p1e2,p1e3,p1e4,p1e5,p1e6";
将它插入在数据库中的一个字符串, 当检索它的部分再次突破像
insert it as a single string in database and when retrieve it in again break in parts like
//一个字符串数组列表
// a string array list
//查询解雇
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'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
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);
//
}
上一篇:德codeByteArray和copyPixelsToBuffer不工作。 SkImageDe codeR ::厂返回null工作、copyPixelsToBuffer、codeByteArray、n