I have created a Room database and i am trying to implement the following functions
public int getRowCountSenderHelper()
    {
         return senderHelperDao.checkRowCount();
    }
    public SenderHelper getOneChat()
    {
        return senderHelperDao.getOneChat();
    }
Now the android is giving me this error.
java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
Now i cannot use AsyncTask since they are deprecated and i cant call senderHelper.getOneChat() and senderHelperDao.checkRowCount() in a Thread because it need to return a value and i fear then when new thread goes to work in background the main thread may return empty value.
Any way to tackle this problem will be appreciated
 
    