Android Notepadv1 Tutorial - Persistent mNoteNumber?
- by Chris L.
So I did the Notepadv1 tutorial. It worked great. No problems. I would however like some explanation on why the mNoteNumber remembers the last number of the item I created.
So the class starts as follows:
public class Notepadv1 extends ListActivity {
private int mNoteNumber = 1;
That's fine, I understand that. The only other time the mNoteNumber variable is used is when you add an item it creates a note with that number and then increments it to the next number as follows:
private void createNote() {
String noteName = "Note " + mNoteNumber++;
Those are the only two references to the variable mNoteNumber. When I press the Home button and then reopen the app, I add a new note but instead of adding a second "Note 1" it remembers that the last note I added as "Note 3" so it makes "Note 4". So I don't get it. Does Java/Android remember the last state of variables?
If anyone could give me some explanation that would be great THANKS!