Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In my app i want to add a new feature that consist in having a list of object's bought by the user. So, when the user buy something he add's that object to the list. Later, if he starts the app again,there should be all the items added in the list.
The object will have some parameters (name, bought date, price, etc etc). My question is: is this a case to use sqlite?
If yes, In the activity with the list of the objects, everytime the activity starts I will have to load the table from database?
The answer to your first question is "yes". The answer to the second is, also, "yes".
Should I use sqlite?
Well, it depends on your preference and the scenario,
If you are using a webserver and updating the webserver, no need
to use a sqlite since you can ping a query to server and show the
objects for the list
If you are not using a webserver you can use Sqlite for this
scenario since you can perform all the
CRUD(Create,Read,Update,Delete) operations for the Sqlite
Advantages and disadvantages of using SQlite
Pros:
If your application gets closed the in memory data will be lost, but after that you will be able to restore the state from the database if you have one
Especially for the case of complex calculations it is good to store the result once in the database and not recalculate it multiple times on demand
The database will untie your UI from the internet connection and thus you will be able to display results even if there is not internet connection
Using database you will be able to fetch the updated data from a background service, without impacting your UI
Organizing your data in database usually makes it a lot easier to manage all the application data.
Cons:
Adding database will require a bit of additional effort on your side
Sinple Line :: Go for Sqlite solution
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
My question is whether it is more efficient to getChildren in a query and then have all your if else statements sorting the data
Or whether it would be better to have multiple calls to the database which are obviously already sorted?
I would assume getting the children would be better since you are only making one call to the database?
My question is whether it is more efficient to getChildren in a query and then have all your if-else statements sorting the data Or whether it would be better to have multiple queries which are obviously already sorted?
Reading all the data within a node at once sounds not as a good solution to go ahead with. When you attach a listener on such a reference, you are reading all direct children that exist beneath that node, including the nested ones. Filtering the results on the client might be considered a waste of bandwidth and resources.
Suppose you have a node with 1000 objects and you are looking for only three of them. Imagine what would be the size of the result set when getting all 1000 objects? I can imagine that it will be huge. So the best option that you have is to use a query a do the filtering directly on the server. In this manner, the size of the result set will be very small, because only three elements will be returned and not 1000. So basically you are getting only the results you are interested in.
I would assume getting the children would be better since you are only making one call to the database?
That's actually the opposite. There nothing wrong in creating multiple Firebase database calls.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm basically creating an android application which takes around 8 forms (forms consist of EditText field and CheckBoxes) and will store them in a database, so that it can be later synced/added to a pre-existing database (Microsoft SQL 2008).
Which would the best way to store and sync (maybe daily or weekly) data to a pre-existing database in my case. I do not have much experience in android backend, as I've only ever worked with shared preferences to store data locally, so a simpler solution will ease this process. Cheers!
Edit:
TLDR: This question was asked to find out, which route shall be taken when one needs to store data taken from a form filled by the user so that it can be later synced with an existing database (which in my case is a Microsoft SQL 2008). The main aim of the android application was get the various databases and push it to the cloud.
As of 24/1/17: I've created a SQLite Database and have begun storing the data, I'm still not sure which method would be the best to export the data. I will keep on documenting the progress.
You could look at azure cloud services link, you need some knowledge about odata.
or
You could try firebase link, understanding of json is required.
Because you have knowledge about sql I suggest you have a look at some tutorials for linking sql with azure or sqlite with azure.
Use a POJO and store them to firebase. Check this and this or watch this video. hope it helps.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Hey guys I'm working on an Android App with Android Studio and I need a database like mlab(mongoDB). But Android doesn't support mlab. I can't just use SQLite because my data has to be saved also when my application is not running.
For example if my user signs in, their profile photo and other information should be saved in the database and I also want to code something like a friend request which also should be saved in the database.
I googled so much but I didn't find a good solution.
I hope someone can help me.
You asking about two separate things. mLab is a Database as a Service which uses MongoDB, while SqLite is just a database.
You can save data while your application is not being used with either option, simply look into background Services and other parts of the Android API that allow background tasks.
If you want to save data to a database that is not on the device, you'll need to look into the documentation of the service to determine the best way to interact with your database. In the case of mLab, they allow both custom drivers and a REST API for interacting with your database.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I was designing the classified app in android which takes the data from the db hosted at run time. I have designed it and it is working fine but it is very slow as application has to fetch the data from the server and which take much time. I want to reduce the time by some way that user get the data immediate and also can get the data offline with out internet.
Can any one suggest me the best way for store the data in the mobile app or any other way?
can i create a xml and store it on user mobile?
Please let me know.
thanks in advance.
itin
One way is to do this by ContentProvider.
Another way is to use a framework like ORMLite, an Object Relational Mapping.
In my opinion you have two good methods . Fist one ;use store procedures ,triggers and functions to get data from database .Second method get data by using service like json do not use xml(soap).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
what are the best practices to save content data when the device is offline or when you have already downloaded some content that shouldn't be retrieved from server again?
Is SQLite the best approach to achieve this? If the information that I want to store is retrieved from an API as a JSON should I create a database structure to parse and insert it?
I know that the above are different questions but the purpose is the same.
Using Sqlite is a bad idea as it is extremely slow and takes up a lot of unnecessary space. When possible serializing objects or using SharedPreferences should be prepared to sqlite (unless of course you have a database structure). For caching and storing data pulled from the internet, I recommend robospice: https://github.com/octo-online/robospice. It's a very well done library, easy to use, and should be used any time you download data from the internet or have a long-running task.
I would say that it depends on the type of data you're saving. Sqlite is not always a bad idea. It's slower than storing an array in memory, but if you're handling a 500-entry address book an array is going to be a lot more clunky than a database.
Robospice looks interesting.