This a straightforward question but I can't find any clear information to help me make my decision.
I have an application with 2 forms (2 activities) that are filled in for a given object, cleared and then filled in for the next object. This maybe be done more than 100 times during a run of the given application. So the backstack could be populated with 100+ activities.
All that data is saved into an sqlite database, so should I be allowing the backstack to fill like that? What are the performance implications - storing hundreds of instances of a form would surely start to take a toll. Are these instances stored efficiently enough that I don't have to worry about this, or does the backstack have some sort of limit anyway? Is there any way to make the backstack store just the entered data, or is the saved "instance" composed of nothing more than the entered data anyway? Is querying an sqlite database onbackpressed instead that much less efficient than allowing the backstack to load previous forms? Is there a way to reload an existing instance ala FLAG_ACTIVITY_SINGLE_TOP
and clear the existing entered data, but save it (the data) in the backstack?
I have constantly been reading/told that it is a bad idea to modify the behaviour of the back button, backstack and activity management of android, which makes me tentative about doing so as an android novice.
I reckon the data from both forms would be no more in size than the 2nd paragraph of this question fyi.
Thank you for your help.
EDIT in response to JoxTraex:
fill -> add -> fill -> add -> n -> commit
could then be
fill activity A and then instantiate and fill B -> transact to DB -> REinstantiate and fill A then REinstantiate and fill B -> transact to DB -> n -> commit
have I understood correctly?
If so reloading rather than instantiating a new instance of A and B should solve the backstack problem as there will only be ever 2 activities in it.
Which leads to confusion about what onbackpressed
will do - will it reload previously entered data or work no more than twice as there were just 2 activities in the backstack?
You should not use the stack to trace the data nor should you have 100 instance of an activity!
You should instead load the data from the database dynamically as needed. Also if you have that activity being done 100 times, then you already have a problem with your design, make it easier so that the user doesn't have to do this pattern:
fill -> commit -> fill -> commit
Instead change it to just:
fill -> add -> fill -> add -> N -> commit
This way you simplify your design and make more effective use of your form.
fill
in my case, is filling ALL respective data (ideally on one screen) add
means push that data into the transaction and commit
means to finish the transaction and push everything. N
means to repeat the fill -> add
pattern. After completing the transaction go back to your main menu/view of the new respective data. Also I would recommend to instead have a ListView that is populated with all the entries instead of using the stack of activities.