Nesh Mogan Nesh Mogan - 16 days ago 9
Android Question

How to save sequence number state across multiple invocations of an Android app?

I am working on an Android printing application that works with a thermal printer. The app works well (prints desired output). However, I am not sure how to set the running number (sequence number) for the receipt. For example, Running number start from 001 -> 002 -> 003. Once I close my application and restart it, it starts over with 001 -> 002 and so on. I would like the running number to continue from the last used number even if the app is closed and restarted. How can I achieve this?

Answer

You Can Save the last receipt number in sharedpref or sqlite or file, Then retrieve the same and start the receipt number....

Refer Shared Pref - https://developer.android.com/training/basics/data-storage/shared-preferences.html