I have five activities for the different country.like, India, Sri Lanka, Argentina, America, China and each activity contains place picker activity to pick a current place.
When I press a button on the India activity, the place picker activity is launched.and pick the location and display this location on India activity.like this when i press a button on Argentina activity, the place picker activity is launched.and pick the location and display this location on Argentina activity.
for this, I want to send some data back to the previous screen. I used the shared preferences, but when I pick the location from any activity it always displays data in India activity instead of previous activity from which I launched the place picker activity.
in short, I need to get a result from this Place picker Activity and then get back to the previous one.
below is code where i send my data from place picker
CharSequence city = place.getName();
CharSequence cityAddress = place.getAddress();
SharedPreferences settings = getSharedPreferences("city_address", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putString("city_address", (String) cityAddress);
editor.putString("city_name", (String) city);
editor.commit();
Intent intent = new Intent(this, India.class);
startActivity(intent);
and this is code in each activity to display data
SharedPreferences settings = getSharedPreferences("city_address", Context.MODE_PRIVATE);
String n = settings.getString("city_name", "");
String a = settings.getString("city_address", "");
cityname.setText(n);
cetlocation.setText(a);
I've read about the StartActivityForResult() method, but I'm not yet sure how to use it properly, any examples?please help me I am new to the android studio.