I am making an Android app where I am implementing a Shopping Cart. When the user selects an item, it is added to his/her shopping cart/bag in the app. Once he/she adds an item, he's presented with the menu again, where he can add more items. Now I want to know how do I save these items during the buying process. I mean the items that are being saved in the bag, how do I save them in my android app? Shall I use the Android SQLite database? or use putextra/getextra and navigate through activities? or shall I use Global Variables (something like subclassing the Application class)?
Or is there any other better way to implement such a thing? The details that I need to show in my bag are: the name of the product, its price, quantity and a few other attributes/options related to the product.
A high number of abandoned carts can take up server bandwidth and significantly slow down your website, which is a major problem for your customer experience. A slow website can be incredibly frustrating to customers, causing them to give up or do their shopping elsewhere.
Passing the shopping cart items around in extras or using an Application class is too volatile. If your app crashes, the user exits the app, android decides to close your app, .. basically anything that closes your app.. The user will lose the contents of their shopping cart.
SQLite would be a good option for storing data like this. You could also store the shopping cart in an xml file on the user's phone.
Is there any other better way to implement such a thing?
First of all you have to understand that what is Shopping Cart Software? However you may develop shopping cart client (Tutorials) in android.
The shopping cart system has server-application (which you may develop using the RESTful
web-services,servlets and filter) and client-application (you may develop a web-client or Android client). The RESTful web-services, which expose Shopping Cart API
and you may interact them (Web-services) with Android UI and network API (Apache http client).
One way is to have your shopping cart stored in a public static variables. Since I had to implement the shopping cart for few of my Android apps, I have tried to create a library project for it.
You can check it out here: https://github.com/tonyvu2014/android-shoppingcart and an example on how to use the library is here: https://github.com/tonyvu2014/android-shoppingcart-demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With