I'm making an app that allows me to keep track of my income/spendings in Android. I want the app to be able to show me incomes and spendings over a certain timespan.
What I've got so far is this
public void buildArray (String num, String kat, String titel) {
Set<String> mySet = new HashSet<String>();
mySet.add(num);
mySet.add(kat);
mySet.add(titel);
saveData(mySet);
}
public void saveData (Set<String> setName) {
SharedPreferences sp = this.getActivity().getSharedPreferences("Utgifter", Context.MODE_PRIVATE);
SharedPreferences.Editor edit = sp.edit();
Date date = new Date();
edit.putStringSet(String.valueOf(date), setName);
edit.commit();
}
For every entry the user makes I want to store four values. The amount, the category and a title for the entry, and the current time as the key.
My question is how do I read stringsets from the SharedPreferences and is using the date as a key a good idea? Is there anyway to loop through all the saved values and read the ones in a certain time interval?
Thanks!