Reputation: 692
I have two activities. Activity 1 - connects to the database and gets some data. Activity 2 - Connects to the database and pushes new data.
There is a button that opens activity 2 from activity 1.
When i open the database connection in activity 1, should i close it before opening activity 2 and then reopen the connection in activity 2?
OR , Is there a way to open the database connection in activity 1 and then just pass the connection to other activities?
Upvotes: 1
Views: 53
Reputation: 2216
I suggest these three solutions
onStop()
invocation and open when onStart()
called in your activities, but it is not a good solutionyourIntent.startActivityForResult()
, then you should to return new data from second to first by intent and add it to db in onActivityResult()
methodP.S. sorry for my bad English
Upvotes: 2