Made the database access synchronous to stop the random crashes. Seems to have issues in getting data over bluetooth though now.