0

I have four activities. Say A,B,C and D. What happens in my app is user fills data in each activity. First A then on completing the form goes to B then C and finally D. What I require are as follows:

  1. Data inserted by user in activities A,B and C to be available in D.
  2. If user navigates back like from D to C, I want the data user inserted previously to be rendered in their respective fields.

Currently I am using intents to transfer data between the activities but it seems inefficient and tidious plus not a smart way. I thought of using shared preference or database but the data required are temporary. I mean once the process completes I don't require them in future.

I would like to know if there is a better way to make data available and persist in the activities.

SarojMjn
  • 569
  • 1
  • 7
  • 23
  • You can use singleton pattern. – Glenn Jun 17 '14 at 01:12
  • You can try use service too! – Tim Jun 17 '14 at 01:35
  • use shared preferences, after not used, remove them – Fahriyal Afif Jun 17 '14 at 01:41
  • @FahriyalAfif I made custom java objects for each page thinking it would make it easier. they are parceble. Is it possible to save custom object using shared preferences? – SarojMjn Jun 17 '14 at 01:52
  • @Tim Can you be a little bit more clearer. You see I am a beginner and have little knowledge. which service are you talking about. – SarojMjn Jun 17 '14 at 01:54
  • @Glenn-- I beleive singleton pattern is for making data persist. Thank you for your reply. I am looking over it. – SarojMjn Jun 17 '14 at 01:57
  • http://developer.android.com/reference/android/app/Service.html u can use the service, to hold your data, and you can access/edit the data by binding it to the service! but, this method might be overkill for ur simple app – Tim Jun 17 '14 at 02:10
  • I have this question sometime back and this thread helped me a lot [What's the best way to share data between activities?][1] [1]: http://stackoverflow.com/questions/4878159/android-whats-the-best-way-to-share-data-between-activities – aksdch11 Jun 17 '14 at 02:50

0 Answers0