write messages into database and show them in activity