java - Why wont my app save 2 values and then display them the next time the app is open? -


I have recently learned about the shared pages and now I have tried to put it in my code. I have 2 integer values ​​that are called counter and counterps. What I want to do is that the app will save prices in every 5 seconds and then when the app is completely shut down and completely reopened (the phone is turned off and again for example) I Want to see if the values ​​were saved (if they were too) is bigger than 0, if so, then set existing values ​​to people who have saved the old ones. Although I set a number for the values ​​inside the app and waited five seconds to save and when I completely restarted the app, the value came in just as 0. Why is this and someone can tell me how to fix it? Secure vs. Create (Bundle Saved Instantstate) {super.onCreate (SavedInstanceState); setContentView (R.layout.activity_my); Shared References = Received Reference ("ShipData", References. MODE_PRIVATE); Last shared pages Editor Editor = Savings.edit (); Int counter = saving. Gate ("ship counter", 0); Int counter PS = SavingsGate ("Ship counter PS", 0); If (mShip.getcounter () == 0) {If (counter> gt; 0) {mShip.setCounter (counter); MShip.setCounterPerSec (counterPS); }} // Save the value in every five seconds under the new timer class (5000, 1000) {public zero onfinish () {editor.putInt ("shipcraft", mShip.getCounter ()); Editor.putInt ("Ship CopperS", mShip.getCounterPerSec ()); editor.commit (); This.start (); } }.Start(); }

How to use the handler (Android road) instead of the timer class ? Is it appropriate in your case?

For more information:

I know the question was posted a while ago. Just answering for this future questions ... Thanks.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -