CB-4760 Remove docs for WebSQL and replace them with a Storage options overview.
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/d27fff8b Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/d27fff8b Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/d27fff8b Branch: refs/heads/master Commit: d27fff8b554007d8d39f0725afbdcdd8453acdab Parents: 37c6f0c Author: Andrew Grieve <[email protected]> Authored: Thu Oct 24 11:36:18 2013 -0400 Committer: Andrew Grieve <[email protected]> Committed: Thu Oct 24 15:01:22 2013 -0400 ---------------------------------------------------------------------- docs/en/edge/config.json | 13 +- .../edge/cordova/storage/database/database.md | 114 -------------- .../storage/localstorage/localstorage.md | 118 --------------- .../cordova/storage/parameters/display_name.md | 22 --- docs/en/edge/cordova/storage/parameters/name.md | 22 --- docs/en/edge/cordova/storage/parameters/size.md | 22 --- .../edge/cordova/storage/parameters/version.md | 22 --- .../edge/cordova/storage/sqlerror/sqlerror.md | 43 ------ .../storage/sqlresultset/sqlresultset.md | 149 ------------------- .../sqlresultsetrowlist/sqlresultsetrowlist.md | 135 ----------------- .../storage/sqltransaction/sqltransaction.md | 108 -------------- docs/en/edge/cordova/storage/storage.md | 74 ++++----- .../cordova/storage/storage.opendatabase.md | 68 --------- 13 files changed, 32 insertions(+), 878 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/config.json ---------------------------------------------------------------------- diff --git a/docs/en/edge/config.json b/docs/en/edge/config.json index 76be7b7..12d3951 100644 --- a/docs/en/edge/config.json +++ b/docs/en/edge/config.json @@ -179,18 +179,7 @@ "cordova/splashscreen/splashscreen.hide.md" ], "storage.md": [ - "cordova/storage/storage.md", - "cordova/storage/storage.opendatabase.md", - "cordova/storage/parameters/name.md", - "cordova/storage/parameters/version.md", - "cordova/storage/parameters/display_name.md", - "cordova/storage/parameters/size.md", - "cordova/storage/database/database.md", - "cordova/storage/sqltransaction/sqltransaction.md", - "cordova/storage/sqlresultset/sqlresultset.md", - "cordova/storage/sqlresultsetrowlist/sqlresultsetrowlist.md", - "cordova/storage/sqlerror/sqlerror.md", - "cordova/storage/localstorage/localstorage.md" + "cordova/storage/storage.md" ], "inappbrowser.md": [ "cordova/inappbrowser/inappbrowser.md", http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/database/database.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/database/database.md b/docs/en/edge/cordova/storage/database/database.md deleted file mode 100644 index c32adab..0000000 --- a/docs/en/edge/cordova/storage/database/database.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# Database - -Provides access to an SQL database. - -## Methods - -- __transaction__: Runs a database transaction. - -- __changeVersion__: Allows scripts to automatically verify the version number and change it when updating a schema. - -## Details - -The `window.openDatabase()` method returns a `Database` object. - -## Supported Platforms - -- Android -- BlackBerry WebWorks (OS 6.0 and higher) -- iOS -- Tizen - -## Transaction Quick Example - - function populateDB(tx) { - tx.executeSql('DROP TABLE IF EXISTS DEMO'); - tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); - } - - function errorCB(err) { - alert("Error processing SQL: "+err.code); - } - - function successCB() { - alert("success!"); - } - - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(populateDB, errorCB, successCB); - -## Change Version Quick Example - - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.changeVersion("1.0", "1.1"); - -## Full Example - - <!DOCTYPE html> - <html> - <head> - <title>Storage Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova.js"></script> - <script type="text/javascript" charset="utf-8"> - - // Wait for device API libraries to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // device APIs are available - // - function onDeviceReady() { - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(populateDB, errorCB, successCB); - } - - // Populate the database - // - function populateDB(tx) { - tx.executeSql('DROP TABLE IF EXISTS DEMO'); - tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); - } - - // Transaction error callback - // - function errorCB(tx, err) { - alert("Error processing SQL: "+err); - } - - // Transaction success callback - // - function successCB() { - alert("success!"); - } - - </script> - </head> - <body> - <h1>Example</h1> - <p>Database</p> - </body> - </html> http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/localstorage/localstorage.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/localstorage/localstorage.md b/docs/en/edge/cordova/storage/localstorage/localstorage.md deleted file mode 100644 index 976e50d..0000000 --- a/docs/en/edge/cordova/storage/localstorage/localstorage.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# localStorage - -Provides access to the W3C's -[Web Storage interface](http://dev.w3.org/html5/webstorage/#the-localstorage-attribute) - - var permanentStorage = window.localStorage; - var tempStorage = window.sessionStorage; - -## Methods - -- __key__: Returns the name of the key at the specified position. - -- __getItem__: Returns the item identified by the specified key. - -- __setItem__: Assigns a keyed item's value. - -- __removeItem__: Removes the item identified by the specified key. - -- __clear__: Removes all of the key/value pairs. - -## Details - -The `window.localStorage` interface implements the W3C's [Web Storage -interface](http://dev.w3.org/html5/webstorage/). An app can use it to -save persistent data using key-value pairs. The -`window.sessionStorage` interface works the same way in every respect, -except that all data is cleared each time the app closes. - -## Supported Platforms - -- Android -- BlackBerry WebWorks (OS 6.0 and higher) -- iOS -- Tizen -- Windows Phone 7 and 8 - -## Key Quick Example - - var keyName = window.localStorage.key(0); - -## Set Item Quick Example - - window.localStorage.setItem("key", "value"); - -## Get Item Quick Example - - var value = window.localStorage.getItem("key"); - // value is now equal to "value" - -## Remove Item Quick Example - - window.localStorage.removeItem("key"); - -## Clear Quick Example - - window.localStorage.clear(); - -## Full Example - - <!DOCTYPE html> - <html> - <head> - <title>Storage Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova.js"></script> - <script type="text/javascript" charset="utf-8"> - - // Wait for device API libraries to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // device APIs are available - // - function onDeviceReady() { - window.localStorage.setItem("key", "value"); - var keyname = window.localStorage.key(i); - // keyname is now equal to "key" - var value = window.localStorage.getItem("key"); - // value is now equal to "value" - window.localStorage.removeItem("key"); - window.localStorage.setItem("key2", "value2"); - window.localStorage.clear(); - // localStorage is now empty - } - - </script> - </head> - <body> - <h1>Example</h1> - <p>localStorage</p> - </body> - </html> - -## Windows Phone 7 Quirks - -Dot notation is _not_ available on Windows Phone 7. Be sure to use -`setItem` or `getItem`, rather than accessing keys directly from the -storage object, such as `window.localStorage.someKey`. - http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/parameters/display_name.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/parameters/display_name.md b/docs/en/edge/cordova/storage/parameters/display_name.md deleted file mode 100644 index 7ea80ff..0000000 --- a/docs/en/edge/cordova/storage/parameters/display_name.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# database_displayname - -The display name of the database. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/parameters/name.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/parameters/name.md b/docs/en/edge/cordova/storage/parameters/name.md deleted file mode 100644 index 0e90c24..0000000 --- a/docs/en/edge/cordova/storage/parameters/name.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# database_name - -The name of the database. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/parameters/size.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/parameters/size.md b/docs/en/edge/cordova/storage/parameters/size.md deleted file mode 100644 index 106d730..0000000 --- a/docs/en/edge/cordova/storage/parameters/size.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# database_size - -The size of the database in bytes. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/parameters/version.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/parameters/version.md b/docs/en/edge/cordova/storage/parameters/version.md deleted file mode 100644 index 68197bf..0000000 --- a/docs/en/edge/cordova/storage/parameters/version.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# database_version - -The version of the database. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/sqlerror/sqlerror.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/sqlerror/sqlerror.md b/docs/en/edge/cordova/storage/sqlerror/sqlerror.md deleted file mode 100644 index 8fcbbbc..0000000 --- a/docs/en/edge/cordova/storage/sqlerror/sqlerror.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# SQLError - -A `SQLError` object is thrown when an error occurs. - -## Properties - -- __code__: One of the predefined error codes listed below. - -- __message__: A description of the error. - -## Constants - -- `SQLError.UNKNOWN_ERR` -- `SQLError.DATABASE_ERR` -- `SQLError.VERSION_ERR` -- `SQLError.TOO_LARGE_ERR` -- `SQLError.QUOTA_ERR` -- `SQLError.SYNTAX_ERR` -- `SQLError.CONSTRAINT_ERR` -- `SQLError.TIMEOUT_ERR` - -## Description - -The `SQLError` object is thrown when an error occurs when manipulating a database. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/sqlresultset/sqlresultset.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/sqlresultset/sqlresultset.md b/docs/en/edge/cordova/storage/sqlresultset/sqlresultset.md deleted file mode 100644 index d2262bf..0000000 --- a/docs/en/edge/cordova/storage/sqlresultset/sqlresultset.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# SQLResultSet - -When a `SQLTransaction` object's `executeSql` method is called, the -specified callback executes with a `SQLResultSet` parameter. - -## Properties - -- __insertId__: The row ID of the row that the `SQLResultSet` object's SQL statement inserted into the database. - -- __rowsAffected__: The number of rows changed by the SQL statement, zero if the statement did not affect any rows. - -- __rows__: a `SQLResultSetRowList` representing the rows returned, empty if no rows are returned. - -## Details - -When a `SQLTransaction` object's `executeSql` method is called, the -specified callback executes with a `SQLResultSet` parameter containing -three properties: - -* The `insertId` returns the row number of a successly SQL insertion - statement. If the SQL does not insert any rows, the `insertId` is - not set. - -* The `rowsAffected` is always `0` for a SQL `select` statement. For - `insert` or `update` statements it returns the number of modified - rows. - -* The final `SQLResultSetList` contains the data returned from a SQL - select statement. - -## Supported Platforms - -- Android -- BlackBerry WebWorks (OS 6.0 and higher) -- iOS -- Tizen - -## Execute SQL Quick Example - - function queryDB(tx) { - tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); - } - - function querySuccess(tx, results) { - console.log("Returned rows = " + results.rows.length); - // this will be true since it was a select statement and so rowsAffected was 0 - if (!results.rowsAffected) { - console.log('No rows affected!'); - return false; - } - // for an insert statement, this property will return the ID of the last inserted row - console.log("Last inserted row ID = " + results.insertId); - } - - function errorCB(err) { - alert("Error processing SQL: "+err.code); - } - - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(queryDB, errorCB); - -## Full Example - - <!DOCTYPE html> - <html> - <head> - <title>Storage Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova.js"></script> - <script type="text/javascript" charset="utf-8"> - - // Wait for device API libraries to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // Populate the database - // - function populateDB(tx) { - tx.executeSql('DROP TABLE IF EXISTS DEMO'); - tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); - } - - // Query the database - // - function queryDB(tx) { - tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); - } - - // Query the success callback - // - function querySuccess(tx, results) { - console.log("Returned rows = " + results.rows.length); - // this will be true since it was a select statement and so rowsAffected was 0 - if (!results.rowsAffected) { - console.log('No rows affected!'); - return false; - } - // for an insert statement, this property will return the ID of the last inserted row - console.log("Last inserted row ID = " + results.insertId); - } - - // Transaction error callback - // - function errorCB(err) { - console.log("Error processing SQL: "+err.code); - } - - // Transaction success callback - // - function successCB() { - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(queryDB, errorCB); - } - - // device APIs are available - // - function onDeviceReady() { - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(populateDB, errorCB, successCB); - } - - </script> - </head> - <body> - <h1>Example</h1> - <p>Database</p> - </body> - </html> http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/sqlresultsetrowlist/sqlresultsetrowlist.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/sqlresultsetrowlist/sqlresultsetrowlist.md b/docs/en/edge/cordova/storage/sqlresultsetrowlist/sqlresultsetrowlist.md deleted file mode 100644 index 68f7a5c..0000000 --- a/docs/en/edge/cordova/storage/sqlresultsetrowlist/sqlresultsetrowlist.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# SQLResultSetRowList - -One of the properties of the `SQLResultSet` containing the rows -returned from a SQL query. - -## Properties - -- __length__: the number of rows returned by the SQL query. - -## Methods - -- __item__: returns the row at the specified index represented by a JavaScript object. - -## Details - -The `SQLResultSetRowList` contains the data returned from a SQL -`select` statement. The object contains a `length` property -indicating how many rows the `select` statement returns. To get a row -of data, call the `item` method to specify an index. It returns a -JavaScript `Object` whose properties are the database columns the -`select` statement was executed against. - -## Supported Platforms - -- Android -- BlackBerry WebWorks (OS 6.0 and higher) -- iOS -- Tizen - -## Execute SQL Quick Example - - function queryDB(tx) { - tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); - } - - function querySuccess(tx, results) { - var len = results.rows.length; - console.log("DEMO table: " + len + " rows found."); - for (var i=0; i<len; i++){ - console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " + results.rows.item(i).data); - } - } - - function errorCB(err) { - alert("Error processing SQL: "+err.code); - } - - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(queryDB, errorCB); - -## Full Example - - <!DOCTYPE html> - <html> - <head> - <title>Storage Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova.js"></script> - <script type="text/javascript" charset="utf-8"> - - // Wait for device API libraries to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // Populate the database - // - function populateDB(tx) { - tx.executeSql('DROP TABLE IF EXISTS DEMO'); - tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); - } - - // Query the database - // - function queryDB(tx) { - tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); - } - - // Query the success callback - // - function querySuccess(tx, results) { - var len = results.rows.length; - console.log("DEMO table: " + len + " rows found."); - for (var i=0; i<len; i++){ - console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " + results.rows.item(i).data); - } - } - - // Transaction error callback - // - function errorCB(err) { - console.log("Error processing SQL: "+err.code); - } - - // Transaction success callback - // - function successCB() { - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(queryDB, errorCB); - } - - // device APIs are available - // - function onDeviceReady() { - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(populateDB, errorCB, successCB); - } - - </script> - </head> - <body> - <h1>Example</h1> - <p>Database</p> - </body> - </html> http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/sqltransaction/sqltransaction.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/sqltransaction/sqltransaction.md b/docs/en/edge/cordova/storage/sqltransaction/sqltransaction.md deleted file mode 100644 index 93901d6..0000000 --- a/docs/en/edge/cordova/storage/sqltransaction/sqltransaction.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# SQLTransaction - -Allows execution of SQL statements against the Database. - -## Methods - -- __executeSql__: executes a SQL statement. - -## Details - -Calling a `Database` object's transaction method, passes a -`SQLTransaction` object to the specified callback method. - -## Supported Platforms - -- Android -- BlackBerry WebWorks (OS 6.0 and higher) -- iOS -- Tizen - -## Execute SQL Quick Example - - function populateDB(tx) { - tx.executeSql('DROP TABLE IF EXISTS DEMO'); - tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); - } - - function errorCB(err) { - alert("Error processing SQL: "+err); - } - - function successCB() { - alert("success!"); - } - - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(populateDB, errorCB, successCB); - -## Full Example - - <!DOCTYPE html> - <html> - <head> - <title>Storage Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova.js"></script> - <script type="text/javascript" charset="utf-8"> - - // Wait for device API libraries to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // device APIs are available - // - function onDeviceReady() { - var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000); - db.transaction(populateDB, errorCB, successCB); - } - - // Populate the database - // - function populateDB(tx) { - tx.executeSql('DROP TABLE IF EXISTS DEMO'); - tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); - tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); - } - - // Transaction error callback - // - function errorCB(err) { - alert("Error processing SQL: "+err); - } - - // Transaction success callback - // - function successCB() { - alert("success!"); - } - - </script> - </head> - <body> - <h1>Example</h1> - <p>SQLTransaction</p> - </body> - </html> http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/storage.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/storage.md b/docs/en/edge/cordova/storage/storage.md index b38ad4a..9af19e1 100644 --- a/docs/en/edge/cordova/storage/storage.md +++ b/docs/en/edge/cordova/storage/storage.md @@ -19,63 +19,51 @@ license: Licensed to the Apache Software Foundation (ASF) under one # Storage -> Provides access to the device's storage options. +> An overview of storage options for Cordova. -This API offers storage options based on two different W3C -specifications: +There are several storage APIs that are available to Cordova applications. For +a more complete overview and examples, see +[http://www.html5rocks.com/en/features/storage](http://www.html5rocks.com/en/features/storage). -* The - [Web Storage API Specification](http://dev.w3.org/html5/webstorage/) - allows you to access data via simple key/value pairs. See the - section on localStorage for complete details on this interface. +## LocalStorage -* The - [Web SQL Database Specification](http://dev.w3.org/html5/webdatabase/) - offers more full-featured database tables accessed via SQL queries. - A summary of this interface appears immediately below. +This API is provided by the underlying WebView implementations. It provides +synchronous key/value pair storage. Refer to [the spec](http://www.w3.org/TR/webstorage/) for more details. -Cordova provides access to both interfaces for the minority of devices -that don't already support them. Otherwise the built-in -implementations apply. +### Platform Support -## Methods +- All of them :) -- openDatabase +### Windows Phone 7 Quirks -## Arguments +Dot notation is _not_ available on Windows Phone 7. Be sure to use +`setItem` or `getItem`, rather than accessing keys directly from the +storage object, such as `window.localStorage.someKey`. -- database_name -- database_version -- database_displayname -- database_size +## WebSQL -## Objects +This API is provided by the underlying WebView. +The [Web SQL Database Specification](http://dev.w3.org/html5/webdatabase/) +offers more full-featured database tables accessed via SQL queries. -- Database -- SQLTransaction -- SQLResultSet -- SQLResultSetRowList -- SQLError +### Platform Support -## Accessing the Feature +- Android +- BlackBerry 10 +- iOS +- Tizen -As of version 3.0, access to Storage APIs is built into Cordova, and -does not require using the CLI to add plugins as described in The -Command-line Interface. +## IndexedDB -If you are using the older set of Cordova tools that precede the CLI, -the following platform-specific configuration settings are still -required: +This API is provided by the underlying WebView. +[Indexed DB](http://www.w3.org/TR/IndexedDB/) offers more features than LocalStorage but fewer than WebSQL. -* Android (in `res/xml/config.xml`) +### Platform Support - <feature name="Storage"> - <param name="android-package" value="org.apache.cordova.Storage" /> - </feature> +- Windows Phone 8 +- BlackBerry 10 -* BlackBerry WebWorks (in `www/config.xml`) +## Plugin-Based Options - <feature id="blackberry.widgetcache" required="true" version="1.0.0.0" /> - -Some platforms may support this feature without requiring any special -configuration. See Platform Support for an overview. +* Most notably - The File API. +* More storage options exist through [Cordova plugins](http://plugins.cordova.io/). http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d27fff8b/docs/en/edge/cordova/storage/storage.opendatabase.md ---------------------------------------------------------------------- diff --git a/docs/en/edge/cordova/storage/storage.opendatabase.md b/docs/en/edge/cordova/storage/storage.opendatabase.md deleted file mode 100644 index 310ba6c..0000000 --- a/docs/en/edge/cordova/storage/storage.opendatabase.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -license: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---- - -# openDatabase - -Returns a new `Database` object. - - var dbShell = window.openDatabase(database_name, database_version, database_displayname, database_size); - -## Description - -The method creates a new SQL Lite Database and returns a `Database` -object that allows manipulation of the data. - -## Supported Platforms - -- Android -- BlackBerry WebWorks (OS 6.0 and higher) -- iOS -- Tizen - -## Quick Example - - var db = window.openDatabase("test", "1.0", "Test DB", 1000000); - -## Full Example - - <!DOCTYPE html> - <html> - <head> - <title>Storage Example</title> - - <script type="text/javascript" charset="utf-8" src="cordova.js"></script> - <script type="text/javascript" charset="utf-8"> - - // Wait for device API libraries to load - // - document.addEventListener("deviceready", onDeviceReady, false); - - // device APIs are available - // - function onDeviceReady() { - var db = window.openDatabase("test", "1.0", "Test DB", 1000000); - } - - </script> - </head> - <body> - <h1>Example</h1> - <p>Open Database</p> - </body> - </html>
