Android使用不同的值更新多行

Android使用不同的值更新多行,android,sqlite,sql-update,Android,Sqlite,Sql Update,我有一个表,有3行_id,name和number。我必须用不同的值更新每行的列号。实际上,我的代码是: ContentValues values; ContentResolver cr = getContentResolver(); int n[] = new int[10]; // functions to assign the values to n[] for(int i=1; i<31;i++) { values = new ContentValues(); val

我有一个表,有3行_id,name和number。我必须用不同的值更新每行的列号。实际上,我的代码是:

ContentValues values;
ContentResolver cr = getContentResolver();
int n[] = new int[10];
// functions to assign the values to n[]
for(int i=1; i<31;i++) {
    values = new ContentValues();
    values.put("number", n[i]);
    cr.update(MyProvider.CONTENT_URI_TABLE, values, "_id="+i, null);
}
contentvalue;
ContentResolver cr=getContentResolver();
int n[]=新int[10];
//函数将值分配给n[]
对于(inti=1;i对于这一点,我将使用ContentResolver上的方法。基本上,它采用一个指定要更新/插入/删除的内容的类型数组

虽然它不会简化您正在编写的代码,但它对您正在访问的内容提供商是有益的。这里的好处是,内容提供商可以在事务中应用这些更新