Hello. I can not store data into data base.
//INSERT NEW in POI - works
// VIDEO - works
// AUDIO - not working
The difference is the 1 and 3 SQL queries are called not in FileTransfer.
In AUDIO, consol stop showing on console.log('fileName: ' + value.audiofilename); - this is right before SQL query. Everything works, when there is no SQL query. Are there any limitations or smt? Please, tell me how can I store data in DB in fileTransfer.
Thanks!Here is my code:
function downloadMedia() {
console.log('downloadMedia()');
db.transaction(function(tx) {
var isUpToDateBool = localStorage.getItem('isUpToDate');
if (isUpToDateBool == "true") {
//alert("poi isUpToDate == true");
} else {
//alert("poi isUpToDate == false");Code: Select all
//INSERT NEW in POI tx.executeSql('INSERT INTO "poi" (id, nid, title, body, created, changed, latitude, longitude, createdAt, updatedAt) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [value.nid, value.title, value.body, value.created, value.changed, value.latitude, value.longitude, Date.now(), Date.now()]); // AUDIO if (value.audiopath) { console.log('audio'); try { //download audio var fileTransfer = new FileTransfer(); var pathStr = value.audiopath; var encodedUri = encodeURI(pathStr); var filePath = window.rootFS.fullPath + "/" + value.audiofilename; console.log('fullPath in audio: ' + filePath); fileTransfer.download( encodedUri, filePath, function(entry) { console.log('nid: ' + value.nid); console.log('UrlPath: ' + value.audiopath); console.log('filePath: ' + filePath); console.log('entry fullpath: ' + entry.fullPath); console.log('fileName: ' + value.audiofilename); tx.executeSql('INSERT INTO "poi_media" ( nid, type, UrlPath, filePath, fileName ) VALUES ( ?, ?, ?, ?, ? )', [value.nid, "audio", value.audiopath, filePath, value.audiofilename]); console.log("audio download complete into entry.fullPath: " + entry.fullPath); console.log("audio download complete into filePath: " + filePath); }, function(error) { console.log("download error source " + error.source); console.log("download error target " + error.target); console.log("upload error code" + error.code); }); } catch (e) { // test only console.log('audio download exception: ' + e.message); tx.executeSql('INSERT INTO "poi_media" ( nid, type, UrlPath, filePath, fileName ) VALUES ( ?, ?, ?, ?, ? )', [value.nid, "audio", value.audiopath, value.audiopath, value.audiofilename]); console.log("2 audio download complete into entry.fullPath: " + value.audiopath); } } // end if // VIDEO if (value.youtubevideo) { console.log('video'); tx.executeSql('INSERT INTO "poi_media" ( nid, type, UrlPath, filePath, fileName ) VALUES ( ?, ?, ?, NULL, NULL )', [value.nid, "video", value.youtubevideo]); //console.log("videoUrl: " + value.youtubevideo); } // end if }
});
}