开发者

Save android value and retrieve it again

开发者 https://www.devze.com 2023-04-11 18:35 出处:网络
I have 开发者_高级运维the following void protected void onPaymentSuccess(PaymentResponse response) {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号