Sobes.tech
Junior — Middle

How are elements added to a Bundle?

sobes.tech AI

Answer from AI

In Android, methods like putX() are used to add elements to a Bundle object, where X is the data type you want to store. For example, putString(), putInt(), putParcelable(), etc.

Example of adding data to a Bundle:

Bundle bundle = new Bundle();
bundle.putString("key_name", "value");
bundle.putInt("key_age", 25);

Then, this Bundle can be passed between activities or fragments to transfer data.