Search code examples
javaandroidsaving-data

Recommended read/write practices for saving/loading control data


I've read the android development documentation and some here and I'm still a bit stuck on the approach to take. Right now I'm building a small Android app that really is just a small POS (Point Of Sale) application.

I want the user to be able to save prices for items (inventory) and to be able to later re-use those prices. I don't want to have to make the user enter in the price of the items each time the app is used.

Right now I'm struggling between shared-resources and filesystem/file.

Questions: In this situation, what is the best route? When the user creates a new order, what is the best way of getting the prices?

Is it recommended to have a class with these values also, rather than just reading from a file?

Do you have to have a 1 to 1 ratio of Activity/Class files? Can you instantiate a Class without starting the activity?


Solution

  • In this situation, what is the best route? When the user creates a new order, what is the best way of getting the prices?

    I recommend you to use CursorLoader and calls it on your onCreate method. Don't forget to release this resources before closing your activity.

    Do you have to have a 1 to 1 ratio of Activity/Class files?

    No, you don't.

    Can you instantiate a Class without starting the activity?

    Yes, you can.