Q:

Send data from fragment to activity android C#

i'm new to xamarin android.  i want to send data from fragment to MainActivity. 
i searched google a lot almost all of them was in Java. 

A:

You have few options:

Access the parent activity. 
Create a function called SetData(data) in your activity class. 
Your fragmnet have the "Activity" property, so cast to your activity type and then call the setData function with your data. 
((ParentActivity)this. Activity).SetData(data);  
Use the SharedPreferences
Set (in fragment):
ISharedPreferences prefs = PreferenceManager. GetDefaultSharedPreferences(context); 
ISharedPreferencesEditor editor = prefs. Edit();
editor. PutString("my_data", "some_data");
editor. Apply();

Get (in activity):
ISharedPreferences prefs = PreferenceManager. GetDefaultSharedPreferences (context);
String myData = prefs. GetString ("my_data", "");

