function InitsqlstorageQuerys()
{
var Profiledb="CREATE TABLE IF NOT EXISTS Profile (Id INTEGER PRIMARY KEY ASC,Name TEXT,SurName TEXT,Age INTEGER,Weight INTEGER,Gender TEXT,Rol TEXT,Email TEXT,Points INTEGER,Win INTEGER,Lose INTEGER)";
var ProfileData='INSERT INTO Profile (Name,SurName,Age,Weight,Gender,Rol,Email,Points,Win,Lose) VALUES ("","",0,60,"","0","",1000,1000,0)';
//var Socialdb="CREATE TABLE IF NOT EXISTS SocialMedia (Id INTEGER PRIMARY KEY ASC,Comment TEXT,Social TEXT,Date DATETIME,IdTraining INTEGER)";
var Trainingdb="CREATE TABLE IF NOT EXISTS Training (Id INTEGER PRIMARY KEY ASC,IdUser INTEGER, Date DATETIME,IdGame INTEGER,Name TEXT,Description INTEGER, TimeTotal TEXT,TimeAVG REAL,TimeKm REAL,TimeBest REAL,PointsWin INTEGER,PointsLose INTEGER,Reached INTEGER,Calories INTEGER,Distance REAL)";
var GeoPosdb="CREATE TABLE IF NOT EXISTS Geopos (Id INTEGER PRIMARY KEY ASC,IdTraining INTEGER,Lat TEXT,Long TEXT,VelAVG INTEGER,Velocity INTEGER,Height INTEGER,Time DATETIME,Milestone INTEGER,Distance TEXT)";
var Configdb="CREATE TABLE IF NOT EXISTS Config (Id INTEGER PRIMARY KEY ASC,Param TEXT,Description TEXT,Type INTEGER,ValuesOPT TEXT,ValueSelected TEXT,OrderOPT INTEGER)";
var ConfigData=[
'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Milestone","lblConfigKm",1,"1/0",1,0)',
'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Sounds","lblConfigSounds",1,"1/0",1,1)',
//'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Intro","lblConfigIntro",1,"1/0",1,2)',
'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Language","lblConfigLang",2,"ES|ESPAÑOL/CA|CATALAN/EN_GB|ENGLISH","ES",3)'
];

var Gamesdb="CREATE TABLE IF NOT EXISTS Games (Id INTEGER PRIMARY KEY ASC,Name TEXT,Subtitle TEXT,Description TEXT,Points INTEGER,Duration INTEGER,Difficulty INTEGER, Image TEXT)";
var GamesData=[
'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleFree","lblGameSubTitleFree","lblGameDescFree",500,0,0,"Free")',
//'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleRescue","lblGameSubTitleRescue","lblGameDescRescue",700,30,1,"/hostage.jpg")',
//'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleZoo","lblGameSubTitleZoo","lblGameDescZoo",800,30,1,"Zoo")',
'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleShadow","lblGameSubTitleShadow","lblGameDescShadow",1500,0,2,"Shadow")',
'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleVirus","lblGameSubTitleVirus","lblGameDescVirus",1000,45,3,"Virus")',
];

var totaldbcreated=0;
RunBotdb.executeSql(Profiledb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
/*RunBotdb.executeSql(Socialdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });*/
RunBotdb.executeSql(Trainingdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(GeoPosdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(Configdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(Gamesdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql("Select * from Config", [],
    function(tx, r){
        if(r.rows.length==0)
            for (var i = 0; i <ConfigData.length ; i++) {
            RunBotdb.executeSql(ConfigData[i], [],
                function(tx, r){
                },
                function(tx, e){
                    Lungo.Notification.error(e.message, 'remove');
                });
        }
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql("Select * from Games", [],
    function(tx, r){
        if(r.rows.length==0)
            for (var i = 0; i <GamesData.length ; i++) {
            RunBotdb.executeSql(GamesData[i], [],
                function(tx, r){
                },
                function(tx, e){
                    Lungo.Notification.error(e.message, 'remove');
                });
        }
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql("Select * from Profile", [],
    function(tx, r){
        if(r.rows.length==0)
            RunBotdb.executeSql(ProfileData, [],
                function(tx, r){
                    initViews();
                },
                function(tx, e){
                    Lungo.Notification.error(e.message);
                });
    },
    function(tx, e){
        Lungo.Notification.error(e.message);
    });

}
//definimos las tablas y los inserts por defecto
definimos las tablas y los inserts por defecto
definimos las tablas y los inserts por defecto
function InitsqlstorageQuerys()
{
var Profiledb="CREATE TABLE IF NOT EXISTS Profile (Id INTEGER PRIMARY KEY ASC,Name TEXT,SurName TEXT,Age INTEGER,Weight INTEGER,Gender TEXT,Rol TEXT,Email TEXT,Points INTEGER,Win INTEGER,Lose INTEGER)";
var ProfileData='INSERT INTO Profile (Name,SurName,Age,Weight,Gender,Rol,Email,Points,Win,Lose) VALUES ("","",0,60,"","0","",1000,1000,0)';
var Trainingdb="CREATE TABLE IF NOT EXISTS Training (Id INTEGER PRIMARY KEY ASC,IdUser INTEGER, Date DATETIME,IdGame INTEGER,Name TEXT,Description INTEGER, TimeTotal TEXT,TimeAVG REAL,TimeKm REAL,TimeBest REAL,PointsWin INTEGER,PointsLose INTEGER,Reached INTEGER,Calories INTEGER,Distance REAL)";
var GeoPosdb="CREATE TABLE IF NOT EXISTS Geopos (Id INTEGER PRIMARY KEY ASC,IdTraining INTEGER,Lat TEXT,Long TEXT,VelAVG INTEGER,Velocity INTEGER,Height INTEGER,Time DATETIME,Milestone INTEGER,Distance TEXT)";
var Configdb="CREATE TABLE IF NOT EXISTS Config (Id INTEGER PRIMARY KEY ASC,Param TEXT,Description TEXT,Type INTEGER,ValuesOPT TEXT,ValueSelected TEXT,OrderOPT INTEGER)";
var ConfigData=[
'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Milestone","lblConfigKm",1,"1/0",1,0)',
'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Sounds","lblConfigSounds",1,"1/0",1,1)',
'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Language","lblConfigLang",2,"ES|ESPAÑOL/CA|CATALAN/EN_GB|ENGLISH","ES",3)'
];
var Gamesdb="CREATE TABLE IF NOT EXISTS Games (Id INTEGER PRIMARY KEY ASC,Name TEXT,Subtitle TEXT,Description TEXT,Points INTEGER,Duration INTEGER,Difficulty INTEGER, Image TEXT)";
var GamesData=[
'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleFree","lblGameSubTitleFree","lblGameDescFree",500,0,0,"Free")',
'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleShadow","lblGameSubTitleShadow","lblGameDescShadow",1500,0,2,"Shadow")',
'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleVirus","lblGameSubTitleVirus","lblGameDescVirus",1000,45,3,"Virus")',
];
var totaldbcreated=0;
RunBotdb.executeSql(Profiledb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(Trainingdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(GeoPosdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(Configdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql(Gamesdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql("Select * from Config", [],
    function(tx, r){
        if(r.rows.length==0)
            for (var i = 0; i <ConfigData.length ; i++) {
            RunBotdb.executeSql(ConfigData[i], [],
                function(tx, r){
                },
                function(tx, e){
                    Lungo.Notification.error(e.message, 'remove');
                });
        }
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql("Select * from Games", [],
    function(tx, r){
        if(r.rows.length==0)
            for (var i = 0; i <GamesData.length ; i++) {
            RunBotdb.executeSql(GamesData[i], [],
                function(tx, r){
                },
                function(tx, e){
                    Lungo.Notification.error(e.message, 'remove');
                });
        }
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });
RunBotdb.executeSql("Select * from Profile", [],
    function(tx, r){
        if(r.rows.length==0)
            RunBotdb.executeSql(ProfileData, [],
                function(tx, r){
                    initViews();
                },
                function(tx, e){
                    Lungo.Notification.error(e.message);
                });
    },
    function(tx, e){
        Lungo.Notification.error(e.message);
    });
}
function InitsqlstorageQuerys ( ) { var Profiledb = "CREATE TABLE IF NOT EXISTS Profile (Id INTEGER PRIMARY KEY ASC,Name TEXT,SurName TEXT,Age INTEGER,Weight INTEGER,Gender TEXT,Rol TEXT,Email TEXT,Points INTEGER,Win INTEGER,Lose INTEGER)" ; var ProfileData = 'INSERT INTO Profile (Name,SurName,Age,Weight,Gender,Rol,Email,Points,Win,Lose) VALUES ("","",0,60,"","0","",1000,1000,0)' ; var Trainingdb = "CREATE TABLE IF NOT EXISTS Training (Id INTEGER PRIMARY KEY ASC,IdUser INTEGER, Date DATETIME,IdGame INTEGER,Name TEXT,Description INTEGER, TimeTotal TEXT,TimeAVG REAL,TimeKm REAL,TimeBest REAL,PointsWin INTEGER,PointsLose INTEGER,Reached INTEGER,Calories INTEGER,Distance REAL)" ; var GeoPosdb = "CREATE TABLE IF NOT EXISTS Geopos (Id INTEGER PRIMARY KEY ASC,IdTraining INTEGER,Lat TEXT,Long TEXT,VelAVG INTEGER,Velocity INTEGER,Height INTEGER,Time DATETIME,Milestone INTEGER,Distance TEXT)" ; var Configdb = "CREATE TABLE IF NOT EXISTS Config (Id INTEGER PRIMARY KEY ASC,Param TEXT,Description TEXT,Type INTEGER,ValuesOPT TEXT,ValueSelected TEXT,OrderOPT INTEGER)" ; var ConfigData = [ 'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Milestone","lblConfigKm",1,"1/0",1,0)' , 'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Sounds","lblConfigSounds",1,"1/0",1,1)' , 'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Language","lblConfigLang",2,"ES|ESPAÑOL/CA|CATALAN/EN_GB|ENGLISH","ES",3)' ] ; var Gamesdb = "CREATE TABLE IF NOT EXISTS Games (Id INTEGER PRIMARY KEY ASC,Name TEXT,Subtitle TEXT,Description TEXT,Points INTEGER,Duration INTEGER,Difficulty INTEGER, Image TEXT)" ; var GamesData = [ 'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleFree","lblGameSubTitleFree","lblGameDescFree",500,0,0,"Free")' , 'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleShadow","lblGameSubTitleShadow","lblGameDescShadow",1500,0,2,"Shadow")' , 'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleVirus","lblGameSubTitleVirus","lblGameDescVirus",1000,45,3,"Virus")' , ] ; var totaldbcreated = 0 ; RunBotdb . executeSql ( Profiledb , [ ] , function ( tx , r ) { totaldbcreated ++ ; } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( Trainingdb , [ ] , function ( tx , r ) { totaldbcreated ++ ; } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( GeoPosdb , [ ] , function ( tx , r ) { totaldbcreated ++ ; } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( Configdb , [ ] , function ( tx , r ) { totaldbcreated ++ ; } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( Gamesdb , [ ] , function ( tx , r ) { totaldbcreated ++ ; } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( "Select * from Config" , [ ] , function ( tx , r ) { if ( r . rows . length == 0 ) for ( var i = 0 ; i < ConfigData . length ; i ++ ) { RunBotdb . executeSql ( ConfigData [ i ] , [ ] , function ( tx , r ) { } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; } } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( "Select * from Games" , [ ] , function ( tx , r ) { if ( r . rows . length == 0 ) for ( var i = 0 ; i < GamesData . length ; i ++ ) { RunBotdb . executeSql ( GamesData [ i ] , [ ] , function ( tx , r ) { } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; } } , function ( tx , e ) { Lungo . Notification . error ( e . message , 'remove' ) ; } ) ; RunBotdb . executeSql ( "Select * from Profile" , [ ] , function ( tx , r ) { if ( r . rows . length == 0 ) RunBotdb . executeSql ( ProfileData , [ ] , function ( tx , r ) { initViews ( ) ; } , function ( tx , e ) { Lungo . Notification . error ( e . message ) ; } ) ; } , function ( tx , e ) { Lungo . Notification . error ( e . message ) ; } ) ; }
definimos las tablas y los inserts por defecto
definimos las tablas y los inserts por defecto
//var Socialdb="CREATE TABLE IF NOT EXISTS SocialMedia (Id INTEGER PRIMARY KEY ASC,Comment TEXT,Social TEXT,Date DATETIME,IdTraining INTEGER)"; //'INSERT INTO Config (Param,Description,Type,ValuesOPT,ValueSelected,OrderOPT) VALUES ("Intro","lblConfigIntro",1,"1/0",1,2)', //'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleRescue","lblGameSubTitleRescue","lblGameDescRescue",700,30,1,"/hostage.jpg")', //'INSERT INTO Games (Name,Subtitle,Description,Points,Duration,Difficulty,Image) VALUES ("lblGameTitleZoo","lblGameSubTitleZoo","lblGameDescZoo",800,30,1,"Zoo")', /*RunBotdb.executeSql(Socialdb, [],
    function(tx, r){
        totaldbcreated++;
    },
    function(tx, e){
        Lungo.Notification.error(e.message, 'remove');
    });*/