SQLite database on PhoneGap

后端 未结 5 2022
臣服心动
臣服心动 2020-12-01 03:27

I want to implement SQLite database for iPhone using PhoneGap. I know some basics SQLite database in iPhone native application. But how can I implement SQLite database in P

5条回答
  •  眼角桃花
    2020-12-01 03:33

    It's important to remember that PhoneGap is web apps packaged in a browser component. Everything that applies to mobile WebKit will apply to PhoneGap as well, and the environment in PhoneGap is also very similar to opening an HTML-file in a desktop browser.

    You want what's called a 'Web SQL Database'.

    http://www.w3.org/TR/webdatabase/

    Edit: This specification has been marked as deprecated since the writing of this answer and it's now an officially Bad Idea™ to depend on it.

    In reality, it's based on SQLite in most browsers that support it, but it won't be exactly the SQLite implementation. But it's close. In Chrome or Safari, you can go have a look at it's contents with your developer tools, look at the 'Resources' tab -> Databases (you want to test out basic functionality on a desktop browser before trying in PhoneGap).

    It will work exactly the same in PhoneGap as in desktop browsers.

    Web SQL databases are one implementations of what's more broadly referred to as "local storage". I think that the best introductionary text on that topic can be found in Mark Pilgrim's "Dive into HTML5":

    http://diveintohtml5.info/storage.html

    Still just as valid for PhoneGap as for desktop browsers.

提交回复
热议问题