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 7 years ago.
Improve this question
I am developing an android app which handles a lot of text. I'm confused at the data storage and retrieval, Which one should i use for faster data retrieval? Sqlite or file storage (json files, separate file for each category ). First I thought about sqlite because it is more easy to manage data, but it will take sometime to create tables with almost 1000 rows in each table or i have to ship the database with my app and it will increase the download size and then i thought about file storage. Which one should i use, sqlite or json file as the data creation is a one time process an the rest is retrieval? Can anyone suggest a better way, i'm really, really confused.
Assuming that the table creation only happens once when the app is installed, then unless the table creation is very, very slow you can simply do it at app first install and include some appropriate message to the user on the screen.
Ideally, if your app can do other useful things without using the data then you can let the user use other parts of the app while the table creation completes in the background.
I have found from past experience that creating very large simple tables is actually very fast, but you would need to test to see how long your examples take.
Note also that you have the option, through the onUpgrade method of the SQLiteOpenHelper, to only modify the parts of the database that you need to at upgrade times, so you may not have to recreate the full data base when installing new versions of the app. This also includes mechanisms to avoid delaying app startup by deferring the updates until the database is first used, although that may not be what you want in this case.
If you have a lot of text and data, use greenDAO. It will handle your SQLite related stuff. It's a bit confusing at start, but once you tried it you will never use SQLite on Android without it:
http://greendao-orm.com/
Some interesting links:
http://developer.android.com/guide/topics/data/data-storage.html
http://developer.android.com/training/basics/data-storage/index.html
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 2 years ago.
Improve this question
Will making 2 database in firebase realtime database help to reduce cost and increase daily download limit of 360MB per day?
The simplest way to reduce the cost is by reducing the downloads. You can do that by caching the data on local storage as much as possible and continuously sync sensitive data.
While reading different articles, one article caught my eye. I'll summarize my findings and also add the link to the article.
Optimizations Possible:
Optimize serialized data saved in the database, this can be achieved easily with GSON, a library to handle JSON data that allows changing the name of serialized entities with annotations. (There are many other libraries that can do the same) GSON #SerializedName
Implementing a memory cache that is kept only during the life of the App. This cache works as follows:
User opens the app and goes somewhere in the app where any kind of favorites is listed, let’s say Bus Stop favorites.
The App requests to the memory cache a list of Bus Stop favorites but as the App has just been launched it returns null.
Then the App requests to Firebase only the node containing Bus Stop Favorites, which are downloaded from the internet and then billed once.
A copy of this favorites is saved in the memory cache.
User plays with favorites, adding, removing or editing them.
Every time a modification is done the resulting favorites list is saved in the memory cache and also sent to Firebase (because uploading data is free).
Now the user can leave the App, and unless it is explicitly removed from the recent App stack by the user or killed by Android, the user can come back to the App and continue playing around with the Bus Stop favorites without incurring in extra billing.
Link to the article mentioned.
Hope this helps!!!.
try to derive data from other data (for example if you have a voting app, instead of storing the number of people that voted, the number of people that upvoted and the number of people that downvoted, you can store only the upvotes and downvotes and do maths to calculate the total amount of people who voted)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am building a simple task list app which stores and retrieves tasks from shared preferences using the Gson library. At this point there isn't any noticeable delays or glitches so I'm wondering is it necessary or may become necessary at some point.
For example, if I decide to switch to another local data source like SQLite or Room would it become necessary?
Are background threads necessary if I am storing and retrieving data locally on Android?
It is generally a good idea.
I am building a simple task list app which stores and retrieves tasks from shared preferences using the Gson library.
If you are using apply() on your SharedPreferences.Editor to persist your changes, it is doing the work on a background thread for you.
I decide to switch to another local data source like SQLite or Room would it become necessary?
"Necessary" is a strong term. If you plan on distributing the app, it would be a good idea to use background threads. Whether those are threads that you create, or whether those are threads that something else creates (e.g., Room, RxJava), may vary.
if you mean SQLITE by locally.the answer is YES.
if you are using the raw sqlite queries the compiler will permit you to make queries in UI thread although it is not a good practice and may cause the UI thread to freeze so it will hurt your application performance but if you are using "ROOM" the compiler will throw an error if you try to make database operation from the UI thread.
so
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 4 years ago.
Improve this question
A little background: The main page contains about 25 thumbnail images displayed in a recycle view. I receive a JSON response from an API containing the urls for those images alongside other data.
I save the JSON string in an objectBox database instance and use GSON.fromJSON to create the actual objects when I need to display them. Btw I use the MVVM pattern.
Now there are three scenarios I would like to consider:
1) when changing activities any currently not displayed activity can be deleted at any point by the os without warning and the images with it. Should I cache the images (where? in memory (don't want to waste it) or storage?) or should I just download them again when user returns to the main activity? Seems to me like downloading the images every time user switches the activities would be quite demanding.
2) when user switches off the application entirely and launches it again everything not saved on disk will be wiped off. I would be ok to download the images in this case since it's just one time process and the database will probably need bringing up to date anyway.
3) finally when the phone is not connected to internet the app should display some images even though they might not be current.
So my question is, how should images be cached in scenario like this one and what's the right way to do it?
Can I cache images in objectBox directly or would i be better off with SQLite? Or should i use some other library like Picasso for caching?
Generally yes, images should be cached in at least memory, and depending on your app (how likely is it to be reused,etc) in memory and storage. If you want to support your 3rd point (displaying when offline), you need to do storage caching, and memory caching is optional but probably a good idea.
What library (or if you use a library, I've had good reasons to roll my own on a few times) to use is way off topic for this site, as its mainly opinion. And we'd need lots of specific knowledge of your usecase to advise one over the other.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm seeking assistance on a APP I need to create. I don't have no experience with android app development but, I'm studying and practicing.
I'm trying to build an app to record payments from a list of customers and print a receipt when paid. I download a list of customers with pending balance, using json array into android. Now, I'm confused, don't know if I should use arrays or a database to store the list, since I need to update (upload) later to the server. SQLite seems like an option but, I have to download the list every time user is connected to WiFi.
I guess I have to store the payments on an array and flush it once uploaded.
Can you please tell me what would be the best option for the tasks I'm trying to accomplish.
It depends on your use case. Arrays and sqlite can work independently or together.
If you are going to upload the data instantly after downloading within the same session, then you can keep it in the Array and upload it after what ever you need to do with it. Keep in mind that Arrays will be kept in memory and depending on where you are keeping the array object, they might not persist through the life cycle of an activity or the life cycle of your application.
SQLite on the hand writes data to disk, so you will be able to persist it even after user has backed out of your application.
...since I need to update (upload) later to the server
Based on the above, it seems like you should persist your data on disk. SQLite is one of the options for persisting data. Have a look here to see what else is available for persisting data.
You can load up any persisted data into your array and upload it after you have processed it.
Hope this helps.
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 6 years ago.
Improve this question
I am currently creating an app that is a guide for a game which involves the user navigating through categories and a large amount of information being displayed. For instance, if I wanted to review information regarding a specific weapon, I may navigate through Items > Weapons > Ranged > Bow. What would be the best to to set this up so the app would run smoothly? I may have up to 100 of these different items the user can view.
The two current approaches I am considering is either making a local SQL database of all of these items, and then having one activity that pulls from the database based on what the user selects. The other being to just make string resources and then load those resources depending on what item the user selects. Any opinions or insight would be much appreciated.
I am not sure about string resources but if you are doing "read only" operations on the data and not saving any user input I would suggest NOT using SQLite. The problem with SQLite for this use is that you will have to create the tables and populate the database programmatically the first time that the app is run. (someone correct me if there is another way to do this) Basically you will end up writing all of your information as strings or reading it from a file on the device anyway, it will just get inserted into the database and be accessed from there every time after. Another drawback is that every time you want to update the information in the app you will have to add rules in the "onUpgrade" method of the database handler. Accessing the data from SQLite will be faster than reading files but IMHO it is a way bigger pain than it is worth for just read operations (unless you have massive amounts of data.. "massive" in the computer world happens to be pretty darn big).
I would probably store the data in your own files (XML, JSON, or just plain text) and put it in the assets folder. Using a nice folder structure and good file naming in there would allow you to add new information without having to change your program.
Another option is to build a web database, pull the information from there, and save it to the local SQLite database when there is an update to the information that you saved online. This makes it easy for you to make revisions to the content without having to send out an app update but takes quite a bit more work
The Content Provider is the prefered way to store big data on the android platform and fortunately many tools are available to do the hard work for you. With that said I would hardly consider 100 a large amount of data even on a mobile device. Will the data change? In other words is it static or dynamic? I recommend the Content provider but you could use shared preferences, a resource file or even hard code your values.