Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+10 votes

When I close my android app or the system does, I need the data to be written to the database. What would be the best way to respond to destroying the app? I am currently overriding onDestroy, but I don't think that is the best solution.

asked in CSC490_Spring202021 by (1 point)

1 Answer

+3 votes

I dont know this can answer your question or not, but when you need to go to another activity and want to come back to the previous one, you will do like this:
1. create a new intent to go to another activity with function startActivityForResult(intent,activity)
2. send data in that activity to the database
3. call back by using function finish();
4. calling data from previous activity by function onActivityResult()

answered by (1 point)