Saving and Loading Integers?

Put your problem here if it does not fit any of the other categories.

Saving and Loading Integers?

Postby Bluepanda » Sun Mar 20, 2011 10:18 pm

Hey there!

I have an app with a list of integers that I want saved into a file, (either Internal or External is fine).

Once the app is opened again how do I also load those saved Integers back into the application so I can pick up where I left off in my app?

private static int gold = 0;

If I change the integer gold value to 20, close the app and then re-enter the app the integer value is reset back to 0. How can I save this integer value and then load the value back up when the app opens again?

If it is possible can someone write a quick example of how to save and load an integer from a file? I've read ... orage.html but I do not completely understand it still.

Thank you!
Posts: 3
Joined: Sat Feb 12, 2011 5:18 pm


Re: Saving and Loading Integers?

Postby raj_J2ME » Mon Mar 21, 2011 8:01 am

Hey, I will still recommend you the same link to read and understand. Note down that Your data storage options are the following:

Shared Preferences
Store private primitive data in key-value pairs.
Internal Storage
Store private data on the device memory.
External Storage
Store public data on the shared external storage.
SQLite Databases
Store structured data in a private database.
Network Connection
Store data on the web with your own network server.

Read all these articles carefully and also check the codebase provided there, however I will suggest you to use the SQLite Databases, for the kind of operations you have mentioned.
Thanks with Regards,
Raj - The Kernel
Master Developer
Master Developer
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,


Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 11 guests