I am quite new to Java so please forgive me if this is a silly question. I have an Android project and it contains classes which are linked, let me try break this down...
- MainActivity (where user will enter values from EditText fields, and then the data needs to be stored somewhere).
- CustomUseCase (this class will need to access this data, and use the data from it to do a calculation for a test).
- ParticleActivity (user will enter more data here, that data needs to be retrieved by CustomUseCase and then theres a button that will run CustomUseCase test
- SolutionActivity(results of these tests will be shown here).
Now the data the user inputs needs to be stored in a String list and 3 Double lists. I know how to implement this but I want to know what is the best way to organise this as I am quite new to Object-Oriented programming. Normally I would make these lists static and declare them on the MainActivity, get the user input and access it via the static variables. But I want to try a ore OO approach so I want to build a model where I can get these costs, have it saved somewhere and then retrieve it without having any memory leak etc. I created a class called UserInputSet, here is my class...
public class UserInputSet {
//user inputs 3 costs from 3 edittext fields and each one gets saved in each of these
List<Double> DATAcost = new ArrayList<Double>();
List<Double> WLANcost = new ArrayList<Double>();
List<Double> UTILITYcost = new ArrayList<Double>();
//user enters string names for 1 set of costs
List<String> serviceNames = new ArrayList<String>();
List<String> dimensions = new ArrayList<String>(String);
}
The layout of the MainActivity presents the user with 4 edittext fields displayed horizontally, the first being the String (name), and the next 3 being each cost (Datacost, WLANcost, UtilityCost) and then they should be saved here, and then retrieved by CustomUseCase. What is the best way to do this? Thank you :)
java.io.File? if so, here is a link with a tutorial: Java.io.File Class