I am trying to understand the cause of the error below and how to fix it.
Only the original thread that created a view hierarchy can touch its views.
This is my code snippet.
public void refreshMyRecyclerView() {
new Thread(new Runnable(){
@Override
public void run(){
mValueList = mMyDatabase.fillValueList(); //pulls data from sqlite db
mRecyclerAdapter = new MyRecyclerAdapter(getActivity(), mValueList);
mRecyclerView.setAdapter(mRecyclerAdapter); //error on this line
}
}).start();
}
I am trying to follow good practice by performing SQLite reads off the UI thread. However I am encountering strange errors like the one above and I have no idea what's causing it even after reading similar questions involving the same error description.