• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

I need help with subroutines (methods)

Hello,
In an app that i 'm writing i 've code that is the same for several views, it is code to save/load data in different files views are: parameters, history,personal info, medication. files are parameters.txt, history.txt, medication.txt
How should i create a kind of util class with code in for save/load data?
this is the code for history view:
public class geschiedenis extends AppCompatActivity {
public static final Object EXTRA_MESSAGE = "com.example.Gezondheidzlogin.MESSAGE";
//variables
String jaartal,diagnose,behandeling, titel;
EditText injaartaltext,indiagnosetext,inbehandelingtext;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inputgeschiedenis);
Intent intent3 = getIntent();
}

public void savedata (View view) {

//laad gegevens in in object voor te versturen naar verwerking
String jaartal;
EditText editText = (EditText) findViewById(R.id.injaartaltext);
jaartal = editText.getText().toString() + ",";
//intent.putExtra(EXTRA_MESSAGE, jaartal);
String diagnose;
editText = (EditText) findViewById(R.id.indiagnosetext);
diagnose = editText.getText().toString()+",";
//intent.putExtra(EXTRA_MESSAGE, diagnose);

editText = (EditText) findViewById(R.id.inbehandelingtext);
behandeling = editText.getText().toString();
String result = "GESCHIEDENIS" + jaartal +diagnose + behandeling;
Intent intent13 = new Intent(this, activity_processing.class);
intent13.putExtra((String) EXTRA_MESSAGE, result);

startActivity(intent13);
}
public void startexit (View view) {
Intent intent100 = new Intent(this, startexit.class);
startActivity(intent100);
finish();
System.exit(0);
}
public void startmenu(View view) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
}
thx for help, Rob​
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones