githubのCursorAdapterコードを見る(core / java / android / widget / CursorAdapter.java)
getViewメソッドはmCursor.moveToPositionを呼び出します
public View getView(int position, View convertView, ViewGroup parent) {
if (!mDataValid) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
if (!mCursor.moveToPosition(position)) {
throw new IllegalStateException("couldn't move cursor to position " + position);
}
View v;
if (convertView == null) {
v = newView(mContext, mCursor, parent);
} else {
v = convertView;
}
bindView(v, mContext, mCursor);
return v;
}
ここでCursorAdapterコードを見ると、fillWindowがcore / java / android / database / sqlite/SQLiteCursor.javaと呼ばれる場合があります。
@Override
public boolean onMove(int oldPosition, int newPosition) {
// Make sure the row at newPosition is present in the window
if (mWindow == null || newPosition < mWindow.getStartPosition() ||
newPosition >= (mWindow.getStartPosition() + mWindow.getNumRows())) {
fillWindow(newPosition);
}
return true;
}
コードを読み続けると、最終的にデータベース呼び出しが行われることがわかります。UIスレッドでデータベース呼び出しを行う理由は何ですか?