How to set large data on spinner [closed] - android

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 4 years ago.
Improve this question
I am new in android development. An interviewer asked me a question that how would you set the large amount of data on a spinner. Data is on server which is very large, for example one million strings. How would you set in on a spinner so that user doesn't have to wait much in order to load that data?
I try to find this kind of question here but i didn't get expected answer so i have posted here.

you can store large amount of data in arraylist, ArrayList in Java has a get(int index) method. int is a signed 32 bit value, with a maximum value of 2,147,483,647. You can therefore store about 2.14 billion records in an arraylist.
then you can display arraylist in spinner recycleview. The RecyclerView is much more powerful, flexible. it doesn't freezes the UI. It supports the use Viewholder pattern and can contains 100k+ rows it runs very smooth.

Simply implement pagination and load the data in chunks. If the API isn't enhanced for pagination, download the strings and set them to an ArrayList, then paginate the array by looping through and receiving the data

Related

Firebase retrival, getChildren vs getValue multiple times [closed]

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.

Please Explain The Usage Of FirebaseRecyclerOption [closed]

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 3 years ago.
Improve this question
i am using a FirebaseecyclerOption, but i don't know the use of it and also tell me how it perform it to populate and store data in model class, like it execute each time or its store all the data in the option and populate it into the model class please explain thanks, and another question is how we can get only limited items from the database.
The FirebaseRecyclerOptions class controls how FirebaseUI populates the RecyclerView with data from the Realtime Database. At a minimum you pass it a query or location to get the data from, and a Java class that will be instantiated to hold the data from each row in the view. For more on this, see the documentation on using the FirebaseRecyclerAdapter.
To limit the data shown you have two options. You can either point to a location with less data, or use a query to limit what data is retrieved. The FirebaseUI documentation on querying shows an example of that, and you find even more examples in the regular Firebase documentation on sorting and filtering data.

Database or File-Handling [closed]

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
To put a lot of searchable text in a software, what would be the best method, database or File-Handling system? Keeping in mind that the text is an Asian language with right-to-left orientation. Platform is Windows and Android.
Database is the better option. It has structured format of all your stored datas. Database allows you to fire queries and search for a particular text you want. You can store and fetch data very easily and with good performance speed. You can also delete any unwanted texts which is easy part.
Now incase of File, It is unstructured format kind of data. All your data gets stored below one another in line by line or. Fetching a particular word from bunch of whole paragraph is tedious job. Even You need to hold whole file's object all the time, which occupies more memory.

What I should pick - JSON or SQLite? [closed]

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

Android ListView for Large DataSets [closed]

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 12 months ago.
Improve this question
Android ListView with SimpleCursorAdapter, takes time to display ListView for a large DataSet (for around 7000 records) . Is there anyway to optimize it?
From the log it look like getting the cursor is taking around 4-7 seconds. Let me know if anyone has a solution for this?
A few ideas:
Display data one page at a time. When you scroll down, load more data.
Scrolling through 7000 records to go to the end will take forever. Access your data via a search form. Limit results to 100 records.
If the data is sorted, group items together and provide an index. For example, alphabetical lists can be split into 26 subsets. The first page shows the alphabet, and you have to click on a letter to go to a subset.

Categories

Resources