我正在尝试创建一个异步任务来处理一大堆数据库条目,然后让用户知道该条目是使用附加到自身的 textView 创建的。我知道我无法触摸 内部的视图doInBackground
,但我无法使用任何其他方法。谁能向我解释如何让我的代码在 AsyncTask 中工作?
代码:
private class DBADDITION extends AsyncTask<Object, Void, Object> {
@Override
protected String doInBackground(Object... params) {
DBAdapter my_database = new DBAdapter(getApplicationContext());
logout.append("\n" + "Start" + " ");
my_database.open();
String temp = input.getText().toString();
int i = Integer.parseInt(temp);
for (int j = 1; j <= i; j++) {
db.createEntry("example", 10 + j);
logout.setText("\n" + j + logout.getText());
}
db.close();
return "it worked";
}
protected void onProgressUpdate(Integer... progress) {
}
}