Sam Voss
Android Enthusiast
hey everybody, I have an idea on what I'm going to do with this, the logic behind it i'm pretty sure is solid, but I'm passing it by you all before trying it, for two reasons:
1, i'm tired so its not getting done tonight, and would like to see the responses to your ideas and
2, please let me know if you see an obvious fail of a flaw here.
Alright, so starting off, In java (learned this before Android) when we needed a variable from across an "application", we would have one .java file like this:
so, if I'm going to have lets say a dozen boolean variables in my options menu(such as like check boxes) and on each activity start, just retrieve these, with in the get() method, add something like "all" and returns some kind of them all, probably in an Array/ArrayList, then obvioslly onClose of the activity, just save them by using the set(), then at the end of set(), have a method called called save(), that saves them all. any obvious flaws here? please and thank you!
1, i'm tired so its not getting done tonight, and would like to see the responses to your ideas and
2, please let me know if you see an obvious fail of a flaw here.
Alright, so starting off, In java (learned this before Android) when we needed a variable from across an "application", we would have one .java file like this:
Code:
public class variables{
public int a = 1;
public int b = 2;
public boolean c = true;
public boolean d = false;
public String e = "start";
public String f = "end";
// and so on from here, initializing variables, or actually giving them an //assignment as i did above
// from here down, we would create get() and set() methods such as:
public boolean getBoolean(String x)//we would use the string to identify which boolean we're getting
{
if(x.equals("c"))
return c;
if(x.equals("d"))
return d;
else
return null;
}
//then a set boolean which was same as first, but with a second input var. for what we want the variable to end up as, i'm not going to recreate this
}
so, if I'm going to have lets say a dozen boolean variables in my options menu(such as like check boxes) and on each activity start, just retrieve these, with in the get() method, add something like "all" and returns some kind of them all, probably in an Array/ArrayList, then obvioslly onClose of the activity, just save them by using the set(), then at the end of set(), have a method called called save(), that saves them all. any obvious flaws here? please and thank you!