transferred the code from MainActivity to queryBuilder