我有一个方法,它执行SQLite数据库更新并将其放在AsyncTask中,以使其更快,更可靠.
但是,更新数据库需要两个数据.一个是Integer,另一个是此处显示的PrimaryKeySmallTank类的对象.
在AsyncTask的doInBackground方法的参数中使用params数组,我可以传入一个Integer,但是如果我有两种不同类型的数据呢?
如果整数存储在int ... params [0]中,我不能在params [1]中存储不同的类型对象,那么可以做些什么呢?
对象我想传递给AsyncTask
public class PrimaryKeySmallTank {
int contractNumber;
int customerCode;
int septicCode;
String workDate;
int workNumber;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用的AsyncTask
public class UpdateInfoAsyncTask extends AsyncTask<Integer, Void, Void>{
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
}
@Override
protected Void doInBackground(Integer... params) {
Integer mIntegerIn = params[0]; // this is what I want to do, example
PrimaryKeySmallTank mPrimaryKeySmallTank = params[1]; // different data type to pass in
Database db = new Database(InspectionInfoSelectionList.this);
db.openToWrite();
db.updateWorkClassificationByRow(mPrimaryKeySmallTank, …Run Code Online (Sandbox Code Playgroud)