I want to make a step counter on Android with TYPE_STEP_COUNTER.As you know,
TYPE_STEP_COUNTER will reset when you re-boot the device.So I should conserve the steps.I decide to use SharedPreference to conserve it.
The project structure as follows:
In the MainActivity.java,
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text_step = (TextView) findViewById(R.id.main_text_step);
delayHandler = new Handler(this);
Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
SharedPreferences.Editor editor=getSharedPreferences("DateStep",MODE_PRIVATE).edit();
}
But ,when I put data in StepService.java,it failed. //StepService.java
editor.putInt("step",StepDetector.CURRENT_STEP); editor.putString("date",current_Date);
It says can't resolve symbol editor. can you give me some advive what should I do to conserve data in StepService.java?