Copy data from website to realm database - android

My app needs to use data from different websites. On these websites, there is a search with different chemical ingredients.
How can I programmatically copy this data from website to my realm database?
This database on Realm needs to be saved as a table which has 2 columns: ingredient name, description.

First of all, create an ID for each ingredient, receiving ID, Ingredient, Description. It's the best way to avoid conflict.
Second, you need to assemble a crawler, and this goes beyond your android application, maybe a network service that can be done even in java, identifying the information on each site and inserting into your database. So doing turn your android application get this information from the site.

Related

How can I handle updating the database in my application and at the same time retaining user scores and settings?

I have a phone application that uses a database of words and tests a user to see which words they know. I have a SQLite database with the words that I populate using a console application and this is then deployed as a resource to phones etc.
When the user runs the application then it stores pass fail data in the same database but in different tables.
When I update the application a fresh copy of the words database is installed on the phone and all the user data is lost.
How is this typically handled? Do phone applications that use SQLite have multiple databases with one being used to store user data and the other holding data which can be brought in when the application is first installed or updated?
If multiple databases are used then is it possible to create a look up from one database to the other?
Thanks in advance for any help, advice or links that point me in the right direction.
I would use a file (JSON, or plain text) to ship the words with the app. Then, when the app runs, it reads that file and adds the new words to the database. This won't affect the other tables.
Instead of having to deal with that, we hard code the values into a static method in code. Then at runtime, we see if there is any data in the table and, if not, we grab the hard coded data and do an insert.
In your case, I would also just add a version number of some kind so then, if the version was lower or the table was empty, you do a delete all and then insert your new static data.

Importing html tables into an android app

I plan on displaying dates and times in an android application but I am stuck on how I would implement this.
My Idea:
At the beginning of every month, a new calendar is downloaded. This information is displayed within the app and no internet connection is necessary for the rest of the app usage.
The information is in the form of an html table. How can I import this table, and display it within the App (also allowing the user to view only certain information in the table (querying the table))
Do I have to import this table into an sqlite database? or is there a less complicated way of doing this. I would like to limit the number of times the user has to access the internet, therefore it would be necessary to store the html table within the app itself.
How about save the table as an xml file? With the xml information you can query, or handle the data as array or list
Can you create a way to access your data in a more "friendly-way"? For example you could create an endpoint online where the app will send a request, download the JSON and save that in a internal database (SQLite, check this if you don't know how).
Or, the ugly way would be to parse the table in the device using Jsoup (which you tagged). Then it's the same, you should save it in a database and read the data from there.
By the way, I would not store directly the html table, because then you will need to parse it every time you need something (p.s it will be slow)

Database Structure Differences between Web & Mobile Development

I would like to know the difference between the structure of database on mobile (Eg; SQLite) and the structure of database on web.
For example, on mobile app development, the database table related to
user will only have one row. But, in web (back-end), there would be
many row for user table. So, even though we only have one row, we
still keep creating the user table in SQLite ?
In my App, all the data are coming from Web Services. And I would like to support full offline support. So, it is like i need to create SQLite structure and tables for everything I received from web services.
The other data are making sense. But, for user, there gotta be some
logic in here to for that specifically. I need to store every data I
am storing in my web-services. But, still, it feels wrong to create a
user table which will only have one row in any given situation.
Let's say in Facebook App. News Feeds are storing in database table. But, how they store the logged in user info for offline ? By creating a user table with only one row ?
NO, If I was to do something like that, then the db on the app would be quite different from what is on the server.Things to consider:
On server your user db stores many different users details like name, age, location, phone number etc. While on app you really don't need all the users, but just the current user's details.
If it was something like facebook then On server I would have users tables, photos, friends, posts, etc. On server all the users posts, comments, photos would be saved BUT on the apps end I would only have the currently logged in user details. The tables doesn't need to be the same, you could have less tables on the app.

Simple MySQL database questions - Database per user of application?

Currently I have developed an android application that uses a local sqlite database per installation. The database comes pre-populated with static tables, and the entire point of the application is to allow the user to assign dates/comments with the pre-populated information in each table.
I am looking to bring this online, and move the database to a mysql format, allowing access via desktops and other mobile devices. Is the best way to handle this to assign each new user a new database?
I would strongly avoid creating multiple databases, and instead add relationships to the existing database structure you have with a users table. Each user has an association to each existing object. Keep in mind sharing with other users in the event that you may want to allow one user to see another user's info.
My suggestion is provide an update to the app where after the first launch after updating it pushes their information to your MySQL database and inform the users that they can access their data via other methods now.
how many user to you expect? I would use only one database with a user table instead of hundreds/thousands of databases.
One table for all users (only with user info like id, email, password, etc).
Another table with comments (with user id and his comment), so that you can add as many comments per user as needed. If dates are related to comments put them on this table, else another table for dates as well.

Creating Unique User ID

I am currently using PHPmyadmin to store data in my mySQL database. The android application I am developing requires the user to select some data and this data along with its attributes need to be stored in my mySQL database. I know I have to create a unique table for every user who downloads my application but how do I go about doing this without having access to the program which the user downloads ?
For eg: let us say there are two phones which download my application. I would want to create two tables in my database which the particular phone knows and can access
Creating one table for every user is a terrible approach. Instead you should create a users table, with a unique ID set to auto_increment, to generate those unique IDs. Then use separate tables to store the data you might need, referencing the user ID from the users table.
It might sound a little confusing, but there are lots of good reads about this on the Internet.
You can generate unique user id in php using uniqid(”, true) function.

Categories

Resources