Android | SQLLite: preliminary database update without using SQLiteOpenHelper

My application uses the SQLite database to retrieve information. I have a function that checks if the folder and database are already present, if they will not work on the Internet (I am currently using dropbox to store the db file) and load the database and save it to sd cards, then I will open a database. The database is writable as it allows the user to rate the object. I have two questions.

1.) I would like to provide updates for the database, and then update the application by updating the database if the version number is higher and will replace the existing one. I did some research and from what I found, you can store the xml or json file with the version number and just analyze the information, and if the version number is higher, download a new database.

Can someone provide an example of how this is done, and is it better to use xml or json for this task?

2.) Is there a way to keep the rating in the new version of the database when loading and accessing a new one?

thanks

+4
source share
1 answer

two nights ago I wrote something like that.

  • pack the database structure as an array in the webservice method by reading the field names and field types. array structure is arbitrary.
  • call the web service method and you should get a string representing the JSONArray object if you sent it as json using the json_encode () method in php.
  • read the structure and create a CREATE DB query string for loops.
  • execute the request, so you must have a database.
  • You can also send a lot of information with arrays.
  • introducing each part is difficult, so google it for every part.
  • do not forget to convert field types to SQLite types, such as VARCHAR => TEXT, smallint => INTEGER, ...
+1
source

Source: https://habr.com/ru/post/1403340/


All Articles