Hi i have ready class to do the work you have stated . just need to customize it to your specified database and sql query.
i can give you output in 1 or 2 hr max.
I am professional android , php, sql, c# developer. looking forward for message from you.