How to pass data from one Activity to another [duplicate]

1

I'm creating an app for pizzerias in my city and I'd like to know if you can send data from a ListActivity that contains pizzas to another ListActivity so that pizzas can be added to the list of favorites.

How can I do this?

    
asked by anonymous 29.01.2015 / 22:47

2 answers

2

There are some ways to "talk" between Activities, to simply send some information to another activity, you can use the Bundle as follows:

                    Bundle bundle = new Bundle();
                    bundle.putString("nomeCliente", cliente.getNome(position));
                    Intent intent = new Intent(context, MinhaOutraActivity.class);
                    intent.putExtras(bundle);
                    startActivity(intent);

Now, if you need to create a bookmark system, you need to save this information in the Database or preference file. You can see how to do this here:

How to use SharedPreferences in Android to store, fetch and edit values

SQLite on Android, Understanding and Using

    
30.01.2015 / 08:12
1

Only one fix is putExtra as below:

     Bundle bundle = new Bundle();
                bundle.putString("nomeCliente", cliente.getNome(position));
                Intent intent = new Intent(context, MinhaOutraActivity.class);
                intent.putExtra(bundle);
                startActivity(intent);
    
30.01.2015 / 13:14