How to get only one column data from firebase in android? - android

I need to get the specific child values only using fire base.for example in mysql:
Select table_name.title from table_name
How can I achieve it in fire base using android ?

When loading data from the Firebase Database, you're always retrieving full nodes. So if you want to retrieve a subset from the data, you'll either have to do it client-side or (more likely) create an extra list in the database with just the data you want to load.

Related

Compare two lists in firebase query

In android, I have a list generated by user input which needs to be compared to a list in Firebase Realtime Database. I want to compare if List 1 contains all the elements in List 2.
This data then needs to be displayed in FirebaseRecyclerPagingAdapter.
Is there anyway this can be achieved?
There is no way to compare two lists in a single operation on the Firebase Realtime Database (nor on Cloud Firestore for those wondering). You will have to load the relevant lists from the database and perform the comparison inside your application code.

How can I store database locally in flutter for read only access?

I have constant data that would be delivered with the app source and won't be changing in the future. Data size is few tables each +/- 1000 row x 20 columns. How can I store them in the app?
I should have the option to the filter data on several layers, like filtering table rows by certain value of column, and then further filter the rows by certain values of other column.
How can I load certain table asynchronously when the user opens the screen that will use that table.
Please provide sample code.
Thanks.
The cleanest way is to use a DB for local data. If you need them in a rows and columns way then an SQL like databse is your best option. I've use hive before which is a key value data store that is very good and efficient.
I suggest you add the data to the db on the application's first load and then just fetch when ever the user accesses it again.
Here's a good article that shows the difference between the most popular data stores for flutter.
https://blog.codemagic.io/choosing-the-right-database-for-your-flutter-app/

Adding latest record at the top of Azure Sql table

Iam following this tutorial :- http://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-android-get-started/
to use mobile services with Azure.
Currently when I add items to the table, the data gets stored randomly. I want it to store the items in a such a manner that the latest record comes at the top of the list.
How can I do it?
Thanks
From the looks of that tutorial, the table in the database which has been created is using a UniqueIdentifier (equivalent to a GUID in code) as the Id. (presumably PK).
GUIDs are generated "randomly" and don't sort nicely in chronologically created order. It's not that the data is getting stored randomly. The Guid is randomly generated, and the table/index stores it in exactly the correct place based on it's Id value.
At the end of the day, for such a small amount of information, the order it's stored in the table isn't really important so long as you can retrieve it in the order you want.
From the looks of the demo, the data table also has a _createdAt column on each data entity. Have a look in the TodoItem & TodoAdapter code to find where it actually executes the query against the data store. It should be quite easy to add an OrderBy to that call to force the returned order to sort by _createdAt

How to store data with variable number of attributes in android

I am making application to collect health logs for a research purpose. I wanted some architecture design advice.
My app requirement:
There would be various forms with numerous fields.
This data needs to be stored locally (next phase is to store it on server)
Also we could have new form as the user base increases
The user must also be able to update a previously entered log
Question
For eg :
Form 1 : (Name , Age, Sex )
Form 2 : (Name , Age, college, height )
The actual form has many fields related to health information
Since the data I receive from the user would have varied fields as above, how do I Store the data of multiple forms into the database. Also I want to add the functionality to add new forms to the app, thus making a database table for ever form is not a good idea (in my opinion). I was thinking to store the data as a JSON string in to the data base with the associated form ID.
Option 1. Store each field as its own column in the database, query the database for the appropriate fields to recreate the various forms.
Note - that changing the field value, changes the value for all forms, unless you specify different column names to save the data under for the different forms.
See tutorial on creating an SQlite database to get started.
Option 2. Serialize a hashmap and store the map as a blob in the database. Easy to add new fields without changing your database. Downside: Can't query for individual characteristics (age, sex, etc). When you retrieve info on a person, you retrieve all of it, and pick what you need. (simpler, but less efficient / robust).

Working with lists of data from server

I am going to populate data from server to a listview (endless). What is the best practice for doing this? Should I cache this data to local db?
Update: Usually list contains not much data about each item. But those item types (say it a "company info") I am also going to use for favorites which should always be stored locally. So I would like to reuse the same table for favorites and items temporally downloaded from server.
Firstly as per per your question please be specific about your requirement .
To handle data from server to listview .. The data that is obtained from server ( i.e parsed json , xml etc) need to sotred in some collection say ArrayList or Hash map etc.
These list can be populated from the above collections.
But if you intend to have permanent storage for the data in the app i.e offline browsing etc than you should save the data in sqlite db and use Cursor Adpater etc for showing the list.
So, the way you use the android recommended widgets and views depends upon the your requirement in mind + the optimized way to handle those things in efficient way.

Categories

Resources