I have an app with the SQlite DB inside and MySQL DB on the server.
SQLite:
Table 1: some columns
Table 2: some columns
MySQL:
The same tables and columns.
I want to ask you: Is it possible and is it the proper way for creating such functionality, like:
User starts the app and there is two buttons <=> activities (Activity 1 & Activity 2)
Activity 1: ListView with data from Table 1
Activity 2: ListView with data from Table 2
For example, user chooses Activity 1. The application proposes to user to update the data. If he/she agrees, the app makes connection with the server and updates SQlite DB Table 1 with data from MySQL DB Table 1.
The same is for Activity 2, but now, the data will be downloaded from Table 2.
Thanks in advance.
What you describe is perfectly fine, I suggest creating a content provider to wrap your sqlite db. That way you can take advantage of a lot of framework functions to get your data.
You will have to probably implment CursorAdapter to populate data inside a listView.
Check out this link to know more about COntentProviders and Sqlite
http://www.vogella.com/articles/AndroidSQLite/article.html
Check out this link to know more about cursoradapters
http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/
Check out this Google I/O to check out the architecture you could implement on your app
http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html
Related
I've made the multiple pages to register the people account in my application. But when I try to insert data ,the data inserted but in different rows .Might be it is the matter of passing id of table. The logic is making way into my mind but idk how to implement it.
I'm stuck into implementing the logic.
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/
While Implementing SQLite data base in android
In my Application I have different 5 database tables.
I found two ways to implement this
1)
create different database for each table and respective SQLiteOpenHelper implementation.
2)
Create 1 database and only 1 SQLiteOpenHelper implementation in that, create all the required tables
I have below queries regarding the above methods.
a) The SQLiteDatabase db = this.getReadableDatabase(); will get database in RAM to operate on It
In case 1) we have a separate database for each table so it will load respective database in memory ?
In case 2) We have single database having all the tables so the all the tables will come in RAM ?
b)In case 2 What if one feature updating in one table and other in 2nd table and 1st feature completed its task and calls close on database then what will happen to the 2nd feature which is still in process ? will there be any exception ?
This is mainly a design question.
If your tables make a consistent whole altogether, they should be stored in a same database. If they are independant, completely unrelated, with no common purpose or use case, these are as many databases.
For example: the tables Users, Accounts, AccessRights should be in a same database as the Users do have Accounts that are granted AccessRights.
Keeping data consistent across multiple tables (the model) is actually the purpose of a database.
I'm creating an Android app that will download XML data from my website, parsed xml data will be inserted into 5 separate SQL Lite tables. I have successfully logged into my website, got the XML data & parsed. I not sure how to layout the database code for multiple tables(opening, closing, inserting, selecting).
Also I would like (is this possible) these tables to stay on the device if the user needs to logout and come back to the app at a later time.
Any help or direction would be appreciated.
Thanks
Question title says "multiple databases", body says "multiple tables". I take it to mean "multiple tables".
Just use SQLiteOpenHelper. Create all the tables in onCreate(). Do the opening/closing and CRUD operations the same way you would do on a SQLiteOpenHelper hosting a single table.
Use a search engine to find tutorials about SQLiteOpenHelper in case you need them.
I am writing an app which logs the GPS data in a database. Each time the user starts logging, I'd like to create a new table and save the data in that table. When the user stops logging, the table is closed. So the next time the user starts the app a new table should be created in the current database. How can I add tables dynamically to the current database?
In several different places I have read it is not a good idea to add tables or columns dynamically to a database. But why? and what is the solution?
Changing the schema dynamically makes data migrations you might want to perform on app update much harder. You'll also have to keep track of the created table names, which is doable, but probably completely unnecessary.
I'd say that what you really need is something like a session_id column in the GPS data table.