I'm using Xamarin and want to know how to import data into an sqlite database using a file from within the app itself using code?
Ive created an sqlite database using
string dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "dbchamps.db3"); var db = new SQLiteConnection (dbPath);
Next I want to input data into the database using an SQL file such as
CREATE TABLE championsList (
id int(4) NOT NULL auto_increment,
champName varchar(50) NOT NULL,
PRIMARY KEY (ID)
);
INSERT INTO championList VALUES (1,'Shaco');
I've moved the SQL file into the assets directory and included it in the project but don't know how to execute it
Aucun commentaire:
Enregistrer un commentaire