database - How to use SQLite.Net to create, insert and draw data in Xamarin.Android? -


i new xamarin , android development. making timetable app , have no idea of how create database using sqlite.net. there possibly documentation of commands can used , thorough description somewhere? because find stuffs related java, ios, , other stuffs.

in app, need create, access, insert, modify , draw links between database, unsure of how any.

thanks

using sqlite.net easy in xamarin android/ios/forms. add nuget package "sqlite-net" intp project. add 2 files, sqlite.cs , sqliteasync.cs in root folder. uses orm hance crud functions can used easily.

here few links xamarin understand concepts better.

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/data/part_3_using_sqlite_orm/

https://developer.xamarin.com/recipes/android/data/databases/sqlite/

https://developer.xamarin.com/recipes/ios/data/sqlite/

https://developer.xamarin.com/guides/xamarin-forms/working-with/databases/

https://developer.xamarin.com/recipes/ios/data/sqlite/create_a_database_with_sqlitenet/

edit 1:

include sqlite-net nuget package frank krueger in application.

create file keeping databse related functions. instance dboperations.cs

    public class dboperations     {         public string sqlitedbpath { get; private set; }          public dboperations()          {             string databasepath =   system.io.path.combine(system.environment.getfolderpath(environment.specialfolder.personal), dbconstants.database_path);                 _sqlitedbfilepath = system.io.path.combine(databasepath, dbconstants.database_name);                 sqlitedbpath = databasepath;                 system.io.directory.createdirectory(sqlitedbpath);                  //create database in set path                             sqlite.sqlite3.config(sqlite.sqlite3.configoption.serialized);                  sqliteconnection sqliteconnection = new sqliteconnection(_sqlitedbfilepath);                 sqliteconnection.close();                 createtables();          }      private void createtables()             {                 sqliteconnection sqliteconnection = new sqliteconnection(_sqlitedbfilepath);                 sqliteconnection.createtable<user>();                 sqliteconnection.close();             }     } 

this snippet create database , table object named user in db.

to perform crud operations write

sqliteconnection con = new sqliteconnection(_sqlitedbfilepath); con.insert(userobject); //insert con.delete(userobject); //delete con.deleteall<>(); //delete rows in table user con.update(userobject); //update list<user> userlist = con.query<user>("select * user"); //select 

hope helps you.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -