Save android value and retrieve it again
I have 开发者_高级运维the following void
protected void onPaymentSuccess(PaymentResponse response) {
// Stuff...
}
I want to save a string within a void for example
String key = "JHIJHFEIRUFHEURFGEU5";
And i want to be able to retrieve it again (this string to be saved to phone) after phone restart, closing application.
Use SharedPreferences inside your application. This allows you to save persistent data and retrive it using a key that you specify. Use Editor to modify the values.
this page will show you many techniques you can use to save thing in a persistant manner so that the can be retrieved even after your application has closed / the device has been turned off etc...
Which one of the proposed ways you want to use depends on what exactly you need. You haven't given many details about your situation so I wouldn't know which will work best for you.
精彩评论