Skip to main content

android - Pass data between Activitys before start the new activity -


I am trying to pass any data in some other activity, but when I click on a button the data pass But do not start new activity and when I have data from the past, launch the new activity and see all of my content that I have passed earlier.

This process is similar to shopping cart, add products and then see the list of another activity cart.

I am trying with SharePrerences, but I pass only one data.

  The last shared context mSettings = this.getSharedPreferences (PREFS_NAME, 0); SharedPreferences.Editor Editor = mSettings.edit (); Editor.putString (NOMBRE_TAG, TVNotes.Get Text). ToString ()); Editor.putString (PRECIO_TAG, pantalla.getText () + ""); editor.commit ();   

With putExtra I do not think it works, because I do not know how much data I will pass

  intent = intention (new intention) , Name orbit); Intent.putextra ("some", "value"); StartActivity; String data = getIntent (). GetExtras () GetString ("Something");   

And I do not know other forms to do it.

The process is the same

When you use the shared priority Every "key" like your tag (NOMBRE_TAG, PRECIO_TAG) will save only one item. Which means, every time you save the item with this key, it will replace the old item.

I recommend using the SQLite database

Here are some examples of how to start:



Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -