我正在使用数组将数据发送到我的SQLite数据库.
该数组包含所有选定的值.
private void addContacts(String[] selectedItems) {
manager.Insert_phone_contact(selectedItems);
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
我的SQLite数据库代码在contentvalues中插入上面提到的"selectedItems"数组如下:
public void Insert_phone_contact(String [] contact){
try{
SQLiteDatabase DB = this.getWritableDatabase();
for(int i=0;i<contact.length;i++){
ContentValues cv = new ContentValues();
cv.put(CONTACT_NAME, contact[i]);
DB.insert(TABLE_CONTACTS, null, cv);
DB.close();
}
}
catch(Exception ex){
Log.e("Error in phone contact insertion", ex.toString());
}
Run Code Online (Sandbox Code Playgroud)
只有第一个数组项存储在ContentValuescv中,而不是所有数组元素中.
这段代码有什么问题?
如何在"TABLE_CONTACTS"表中插入所有数组项?
任何帮助将不胜感激.
我正在使用Vb.Net Forms应用程序进行一些UI工作,在我需要匹配某些颜色并根据它更改UI的地方,此刻我很少被绞死以匹配颜色值,
像A_Control.Background = B_Control.Background
我已经完成了将颜色转换为字符串然后匹配,但在某些情况下这没有效果,我想实现一个直接使用Colors变量的函数.
喜欢:
Dim somecolor As New Color()
somecolor = Color.FromArgb(255, 98, 153, 192)
Dim str As String = somecolor.R.ToString() + somecolor.G.ToString() + somecolor.B.ToString()
Run Code Online (Sandbox Code Playgroud)
通过这样做我可以在字符串中有RGB值,然后我可以转换为整数以匹配任何其他颜色,有没有更好的方法来做到这一点?