This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Closed 2 years ago.
I want to query firebase database with name contains the search text, In Android.
My database structure is shown in image.
I want to query first name and last name and get limited records in result.
One way that you can get around this problem is to concatenate first name and last name into a new couple. Something like this: First_Last_Name: "Rahul_Rajesh". Just be noticed that this way causes redundancy and you should avoid it unless you REALLY need it.
Related
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 4 years ago.
Improve this question
I'm writing an application with an internal database.
I'm getting data on database with the arrayList because I have to get different type of data. My question is: are ArrayList the best solution to get data from this database or there are others method to do that?
An ArrayList is one way of reading data from a database. It will be convenient to store all the info from a column in an ArrayList, such as an ArrayList for the name column, or age columns, so on...
Another data structure that you may consider using is a Map such as a HashMap or a TreeMap. This will not only enable you to store the data values but give it a key as well, this way you can refer to the value by using its key. An example of where you may use this if you want to retrieve the names of a person and their age. By using a HashMap, the key could be the person's name and the value could be their age. This would make it easy to retrieve the person's age based on their name.
Maps are used to put information into a database, as can be found by this documentation from Android Developers. The Android Developers documentation also shows that Lists can be used to read data. Essentially, it comes down to your uses. If you are reading multiple columns, you may consider creating multiple Lists whereas if you were reading from two columns, such as name and age, you may consider using a HashMap that way each age corresponds to a name and it is easy to retrieve that age from the name.
I hope that this answer has given you some insight and input into which data structure you have decided to use, but ultimately, it is your choice.
This question already has answers here:
Ship an application with a database
(15 answers)
Closed 7 years ago.
I am currently learning how to use database in Android. For one of my app, I need to stock 500 string values in order to read them.
Actually to fill my database, I read a .txt file at the database creation with all the string values inside. For each lines of .txt (corresponding to a string value), I create a new data in the database. The thing is I know that accessing a file can be long it is not a very good thing if there are thousands of values.
According to that, I have two questions :
Is it really usefull to create a database ? (because I can directly access the string values by reading the .txt)
Is there a better way to fill the database ? Or a way to create a database already filled before the activity creation ? (because currently, each time you close the activity you close the database and each time you reopen it, it recreate and refill the database.)
How about instead of having .txt have a .csv file with values and use org.apache.commons.csv or super csv for parsing the csv file. I haven't used super csv but it provides support for POJO support which i think can be really handy. This will increase your performance and parsing speed. But it would be based on your situation. i would recommend creating a database if you need to perform SQL queries on your data for eg. joins or nested queries. If you just need to display you can use a CSV file.
This question already has answers here:
How can I list the tables in a SQLite database file that was opened with ATTACH?
(17 answers)
Closed 9 years ago.
I am new to android sqlite. i want to get list of table residing in one particular database. Is this possible in sqlite. Can anyone guide me on this. I searched long time for this, dint get any idea.
For example :
My dB name is ABC, in that i have 10 different tables, i want to get the list of table names from that particular Db. Thanks in advance
You need to query the sqlite_master table of the schema ABC .
SELECT * FROM ABC.sqlite_master WHERE type='table';
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Multiple database in single app in android
I have one app with it's database file. Now i want to build another database file in this app to store another kind of data. Is it posible?
Though it is possible to have multiple database in single app, still I will suggest to have multiple tables in single database instead of multiple database.
Here is a solution to create multiple database.
How to add multiple database in single app
This question already has answers here:
How to sync SQLite database on Android phone with MySQL database on server?
(5 answers)
Closed 9 years ago.
I am new to using services. In my application I want to run services in the background. I am creating the same database in MySQL server and SQLite. If I change some data in a table in the SQLite database, does it mean it should automatically store the change in the MySQL-server also?
To answer your question: no, it does not automatically reflect the changes made in SQLite into MySQL.
Why? Because you basically have 2 different databases, although they have the same name (and probably structure). In order for them to communicate and get synchronized, you need to implement some kind of communicating mechanism.
As suggested to you by eggyal in an above comment, take a look here, as a solution for this kind of problem is explained there.