B
B
boomwest2014-10-08 14:10:45
Android
boomwest, 2014-10-08 14:10:45

How to organize the storage and transfer of data in the application between Activities?

There are several Activities, each accepting data from the user.
On the first one, the name is entered, on the second, the date, on the third, some other information is entered.
On the last screen, all collected information is sent to the server.
How to properly store this temporary information?
Due to the large number of transitions - Putextra is not suitable.
I thought to use a temporary table in sqlite, but hesitated.
Now I use the Application class, all data is stored in the properties of this class.
How is it right anyway?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
Copperfield, 2014-10-08
@Copperfield

1) You can make 1 activity and 4 fragments.
2) You can present the received data as a class, and with each intent to a new activity, transfer a seriazable object.

L
linreal, 2014-10-08
@linreal

You can temporarily store in preferences, and clean them after sending.

B
Bolloky, 2014-10-09
@Bolloky

It is quite possible to drive the same Bundle. This is not labor intensive and will protect against unloading, since the application will start from the same place with the same Intent.

Bundle data = getIntent.getExtras();
data.putString( "param100500", "ДЖИГУРДА" );
Intent intent = new Intent( this, Activity100501.class );
intent.putExtras( data );

In addition to this, for reliability, you can inherit all Activities from the parent, where in the onPause () method your Bundle will be saved in Preferences, and in onCreate it will be restored when savedInstanceState == null.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question