For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 9 replies, 3 voices, and was last updated 13 years, 9 months ago by
support-michael.
-
AuthorPosts
-
alonso100MemberHi,
I download a file from internet with 2 columns and x number of records. This is something I save in a database table which I create in a previous step. As long as the application is running, I can search for information according to a text that I enter in a field and application displays all records that were found. If I close the application and start it again the records are gone !!
Why is the database, table or records not permanent ?? Working with a Samsung Galaxy SII.
Creation of DB:
DEMODB = openDatabase(shortName, version, displayName, maxSize)Creation of table:
function createTables(){ DEMODB.transaction(function(transaction){ transaction.executeSql('DROP TABLE abreviations', [], null, errorHandler); }); DEMODB.transaction(function (transaction) { transaction.executeSql('CREATE TABLE IF NOT EXISTS abreviations("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, "abrev" TEXT, "descrip" TEXT);', [], nullDataHandler, errorHandler); }); }Saving records into the table:
function saveRecords(abrev, descrip){ cont = cont + 1; DEMODB.transaction(function (transaction) { transaction.executeSql("INSERT INTO abreviations(abrev, descrip) VALUES (?, ?)", [abrev, descrip] ); }); }November 12, 2012 at 1:20 pm #332232
support-octavioMemberHi Alonso,
As I can see the database abreviations is deleted every once you call your createTables function, so the saved data will be deleted too.
function createTables(){
DEMODB.transaction(function(transaction){
transaction.executeSql(‘DROP TABLE abreviations’, [],
null,
errorHandler);
});November 12, 2012 at 1:28 pm #332234
alonso100MemberHi,
I know that but this is fully intentional. I create the table only once when downloading the file from internet and delete the table so that there are no previous records in the table.
When I start the application again, the process of downloading the file is not necessary anymore, because I want to assume that the information is in the database table.
I probably am not opening the database after restarting the application, so I am searching how to do it.
November 12, 2012 at 3:14 pm #332238
alonso100MemberHi,
it is indeed that I was not opening the DB when searching for records. Since I don´t find any other instruction I´m still working with
DEMODB2 = openDatabase(shortName, version, displayName, maxSize);for opening the DB and then I search for records. My concern ist that I see duplicated databases in the local storage inspector for every time that I make a search. In the image in the attachment, the first DB is when created; then I made 3 searches and I see 6 additional icons for the DB. It seems like the information is not being duplicated but I wouldn´t like that something like that occurs in many Smartphones after the installation.
What is the reason for that ?? do we have another instruction for opening the DB ??
Attachments:
You must be logged in to view attached files.November 12, 2012 at 4:27 pm #332242
support-octavioMemberHi Alonso,
With your last post I understand that the first issue is solved, right?
About the duplicated databases, I’ve replicated this issue and seems to be a bug on Test Center, if you open your generated html with a WebKit-based browser as chrome, you won’t see this issue. I’ve opened a bug and will share the details that dev team find, but I’m almost sure that your data is being stored just once.
November 13, 2012 at 3:46 am #332260
support-michaelKeymasterI agree with octavio that the Storage Inspector should only show 1 db instance. The problem occurs with each openDatabase() call. I typically store the first openDatabase() call in a global variable rather than calling it everytime I want to perform a transaction. Doing this will avoid the multiple db instances appearing in the inspector.
November 13, 2012 at 12:36 pm #332275
alonso100MemberHi,
yes, that is the solution.
For curiosity: what is the meaning of the icon “sqlite_sequence” ?? according to what I see, it seems to be some kind of protocol.
November 15, 2012 at 9:18 am #332340
support-michaelKeymaster>what is the meaning of the icon “sqlite_sequence” ??
I’m not sure what you are referring to. Can you provide more details or a screenshot?
November 15, 2012 at 12:17 pm #332352
alonso100Memberit is very clearly shown in the image above.
November 15, 2012 at 2:55 pm #332355
support-michaelKeymasterDuh! Too many things to keep up with…
see http://www.sqlite.org/autoinc.html
“SQLite keeps track of the largest ROWID that a table has ever held using an internal table named “sqlite_sequence”. The sqlite_sequence table is created and initialized automatically whenever a normal table that contains an AUTOINCREMENT column is created. The content of the sqlite_sequence table can be modified using ordinary UPDATE, INSERT, and DELETE statements. But making modifications to this table will likely perturb the AUTOINCREMENT key generation algorithm. Make sure you know what you are doing before you undertake such changes.”
-
AuthorPosts
