简体   繁体   中英

method that runs only after first install

I am creating an app that get data from the server then save it and work locally with sqlite.

I want to initialize my application with data loaded only after the first installation, saved to sqlite and then loaded from database. For that i want to create a method that save the data locally, how to make sure this method runs only after the first time the user install the app.

I think that the easier way to do this is to check, at every application run, if your database contains a certain value in a config table: if isn't present, populate the db, otherwise do nothing and continue execution.

In this way you could avoid to write platform specific code (native) since you're doing everything from the js layer.

Obviously I'm supposing that you're already using sqlite in Cordova, and that you can execute sql query/insert from js.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM