I'm trying to make a "memory" to save three Dates + Hours in a StringArray. I 'll explain better with code. In my main activity I call this line:
conf.setDateArray(completeDate, conf.getPosition());
The two parameters are (a String, an int with the position of the array [0 or 1 or 2]). My problem comes in the Configuration class:
private String[] strDateArray = new String[3];
private int position = 0;
public void setDateArray(String str, int position) {
SharedPreferences.Editor editor = getSettings().edit();
// The problem is this code, I dont know how to write in the array in
// the position
this.strDateArray(position) = str(position);
editor.putString(KEY_DATEARRAY, str);
//
editor.commit();
if (position == 2) {
this.position = 0;
} else {
this.position++;
}
}
Thank you for your help!
EDIT: an example of what I want to do I want to introduce a date like "20-02-2014 14:14" to the StringArray[0] to let the user get this value when he starts again APP. My intention is to have the last three possible values, when all the array is filled, the position=0 will be overwritten.