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.
Related
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 5 years ago.
Improve this question
I am developing my school's timetable app for android. I am getting timetable data from MySQL database. -> I have access to the timetable, only when I have an internet. But I want to make timetable accessible without the internet. I read that I need to save data from MySQL to the SQLite, and then use them. Can you, please, give me links to the samples how do to that?
I can point you in a direction that you might want to go in, you can try to use a ContentProvider to store and read data on your device offline. Once you create your ContentProvider, make use of your school's API through an AsyncTask (provided you have permission to access it) to format you some JSON to parse in Java with a library like Gson.
Basically this relationship becomes like this:
(Server)----JSON---->(AsyncTask)---->(Parse JSON in Client)---->(Move Parsed JSON data to your app's ContentProvider).
There are numerous articles on things like this:
ContentProvider example:
https://developer.android.com/guide/topics/providers/content-provider-creating.html
(Udacity also has free videos describing ContentProviders and JSON retrieval and parsing.)
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 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 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
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 9 years ago.
Improve this question
In my application, on every launch at first some JSON have to downloaded from server and later I need to show various information by parsing this data one the full app life-cycle. The JSON object is pretty big with almost 5000 JSONArray. Every JSON array is of the following form:
[37,101,"The Blocks Problem",9952,0,1000000000,0,852,0,0,11197,0,16606,0,7279,200,18415,5325,14492,3000,1]
So I have two option:
Save the json string into a file and later read it.
Save the JSON array in SQlite database with almost 10 columns and 5000 rows.
The first option seems to be efficient. But later I have to manipulate the JSON for displaying various information. In some cases, I need to search full array to pick on array information and there are many cases like this. So this would be very time consuming also.
The second option is better for searching and displaying faster. So I approached on with the second option. But the insertion of 5000 rows at a time is time consuming also. I did it in AsyncTask for betterment but it is taking too much time to be executed - parsing JSON and store in SQlite table.
So what can I do? what is the best way to store this huge information and later use it efficiently?
I answered a question pretty close to this today - File or Database? - Best Practice to save Objects on Android-Device. I wanted to add that if inserting 5000 rows is taking too long, try adding them all in a single transaction, or using a bulk load mechanism. It's worth the effort to figure out your insert problem instead of trying to use files.
See this tutorial about bulk loading SQLite