Question

I have couple questions regarding the use of SQLite for my Android App. I think my issues are pretty basic but I just can't seem to figure out the database aspect of the app.

  1. I want the user to enter some data in, lets say Activity A. So the data is now stored in a database. I then want Activity B to retrieve the Activity A data from the database and use it for certain calculations in Activity B.

  2. The data that the user enters, I want it to stay on the screen once the user enters it, closes the app, and then reopens the app. I assume this has also to do with the database. Right now, once I enter in the data in Activity A, then navigate to Activity B, and then come back to Activity A and the data is gone.

I am not looking for the exact code to make this work. I am looking for mostly how the database works and if I can even do the 2 things that I mentioned above. I would really appreciate it if someone could explain this to me.

Was it helpful?

Solution

I want the user to enter some data in, lets say Activity A. So the data is now stored in a database. I then want Activity B to retrieve the Activity A data from the database and use it for certain calculations in Activity B.

This problem can be solved easily with the help of a single SharedPrefrence. SQLite Databases should be used when you want to stored structured data within the app not for storing just a simple name-value pair. In case you need any SQLite tutorials for android:

Android SQLite Database Tutorial

Android SQLite database and content provider - Tutorial

and the docs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top