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 have an app (field data collection) where I used the sign in option and authentication with firebase.
All the other database the default option is to store data as a local SQLite database, however, I want to add the option if the user wants to sign in and transfer the local database to an online database so it can be accessed on multiple devices.
Can I have together firebase and sqlite?
I mean can the user store the data offline and when goes online with a sync button can have the data online in the firebase cloud?
My sqlite database stores data from drop down columns, google maps longtitude and latitude data, voice recordings and images.
I would appreciate your help, and hope you understand my questions!
Yours sincerely,
Tzirineto
Yes, this can be possible. The data in SQLite is stored in the form of tables i.e rows and columns i.e. its a relational database. But the data in the firebase id store in the form of documents i.e. key-value pair. Your first step is to create objects in Java. Then it will be easy for you to dump same objects in both SQLite and in firebase. Also you have to maintain a proper relations among the data using uid in firebase. When the user clicks sync button you have to add the objects in the firebase. In order to do that first you have to retrieve the complete data from SQLite and store it into java objects then send them to firebase. You have to keep a check among relationship that exists among the data. Hope it helps
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 1 year ago.
This post was edited and submitted for review 9 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I only started coding about a month ago and I am trying to add a code or program to my work in order to make it store user input and even after rerunning the program, the input will still be kept. Confused? For example, when you make an account on Facebook, they will keep your email and password so next time you just have to login without making the account again. Something like a database to store value I am guessing?
When a program terminates, it looses all the values stored in variables.
This is because we have a GC (Garbage Collection) mechanism which helps to clear up data which are not used.
In your case, to persist data post restart, we need to store to some external store (persistent storage) rather than keeping in the memory.
Your external store can be a database or can be a simple file.
Create a file and store your values in it. Once you restart the program, read the values again from it.
You would require a storage to store the data, as rerunning will erase all previous data. Any filesystem/db can be used to resolve your issue.
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
I have to store 500-1000 values in somewhere, but i cant decide which one is more efficient(ArrayList vs Database).Can you explain pros and cons of arraylist and database?
thanks...
In memory data structures are always faster than DB.
But tradeoff is between size of data structure and available memory. For your need, arraylist will be faster. But data will be gone once application is stopped or killed.
Database is persistent data store. If your need is to store temp data then arraylist is suitable and if you need to store it permanently then you have 2 options:
Database (standard way, API availalbe, standard practice)
Filesystem (keep your data in data structure till application stops and then write it to a file in encrypted form if security is required.)
If you need, explore about in memory databases for android(sqlite). This is best suitable for you.
the use of array list and the data base is different.
if u doesn't want to store your record permanently then you can use "Array List", but if u want to store your record permanently then u need to use data base.
because when you store the record in Array list those record stored into RAM. records don't store into the secondary storage. but when you store the record in to the data base then records stores into the database.
if your concern about the speed of accessing the data from Array List or data base then arrayList is faster then the database
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
In my web application i have a employee table with employee id,name,designation salary... as attributes which may contain thousands of records in it.. I want to search employee name, so for searching employeename which one will work faster hitting DB every time or create list of employee names once in java bean and iterating it for searching every time... Which one is better..??
By far, even if you have millions of records, it is better to hit the database per request. To enhance this, you can add a key/index on your name field in your employee table and the requests will be faster.
In case the data in your employee table doesn't vary that much, you have another option which is using a cache for your employee table. With this, your access to the data will be even faster since it will look up the employee at cache (usually RAM), but this comes with a more complex design and adding policies for your cache data retrieval and setting periods to update the cache data.
This is depends in few things..
Hitting the DB is IO action and in case you have specific screen/process that does a lot in specific flow of course it will be better to load list from DB once and use it several times, And this is in case that you can be sure that employees list won't be change in DB by other process/Or it can change and this is not critical for you..
If the screen/process make only few hits to get employees it should be hitting DB.
Remember that Hitting DB a lot of time can also load the DB and cause him to be slow.. He can't handle with infinite number of request.
Hope that 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'm trying to count the number of times multiple id's appears in a database table, then using them numbers to put into a JFreeChart.
Im currently unaware how to do this and cannot find code online to do this.
Well I'm certainly no expert but I recently did something similar in an application. You can hardcode the required SQL query strings into your application code and thus, retrieve the required data from your database. You will need a database connector for this. The connector you need depends on what language you are writing code in and what database you are using.
You will receive resultsets where the data from your database is returned as Strings. This includes data that was stored in your database in numeric format so you may need to cast the strings to another format if thats what you require. You feed the result set into a collection structure such as 'ArrayList' (if you are using Java for example). You said you are trying to count id's so you could use searching methods for whatever collection you use to tell you whether the strings in the collection are duplicates, you may need to use a a set (a collection which cant have duplicates) for comparison purposes. There's not that much detail in your question but this should help, just count the duplicates in your collection and keep track of the numbers.
At the end if this you will have a collection of numerical values so you simply feed this to a class which imports the required JFreeChart modules and uses the data to create a chart.
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
Lets say I have a very big file having data. A parser parses it and keeps the data in the following class:
Class Data{
DataHeader header;
List<DataLine> lines;
...
}
Before persisting this data in the DB, I do some validations and processing on it. And I persist it only if there are no errors in it.
Data file looks like:
DATAHEADER|.......
DATALINE|1|....
DATALINE|2|....
... and so on
To process this file in a limited JVM memory, it should be processed in batches and also made sure that it is persisted only if it does not have any errors. Appreciate your help on designing the solution.
With big files, you can't always load everything into memory. You sometime have to create a temp table to store the information.
Read a few lines and store them in a list
Check if lines, making sure the data is correct
If it's good, store the line in the temp table in the database
If it's bad, delete the data in the temp table and stop the process with an error
When the file has been loaded in the temp table
Do you global check (try to do them in the database, don't fetch everything back in the application)
If it's good, copy the data from the temp table into the live table. Delete the temp table
If it's bad, delete the data in the temp table and stop the process with an error