I have created the example code below to explain myself. I have a few EditText fields that need the data stored as "entries" for later use. My question is, what is the best way to store these three variables to be "listed" in another activity. (liAmount, liAccount, and vID). I was just going to use shared preferences, but even with this, I will have multiple entries on the same EditTexts so I don't really know how to properly serialize them...
float liAmount;
String liAccount;
String vID;
btnSaveLineItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(etLineItemAmount.length() == 0 || etAccountName.length() == 0) {
Toast.makeText(NewLineActivity.this, "Fill all fields.", Toast.LENGTH_LONG).show();
} else {
saveLineItem();
createVID();
}
}
});
public void createVID(){
vID = String.valueOf(liAccount.charAt(0) + liAccount.charAt(1) + liAccount.charAt(2) + liAmount);
}
public void saveLineItem(){
liAmount = Float.valueOf(etLineItemAmount.getText().toString());
liAccount = etAccountName.getText().toString();
}
EDIT: I should clarify, I do want these data files to be stored long-term. These are essentially going to be used in a separate activity file to show a list of all previous entries.