简体   繁体   中英

Save a Sqlite database to a file

I have a Sqlite database which I retrieve the data inside and insert them in a List <T> . I would like to be able to save this list in a file inside the device, or directly the SqLite database in order to be able to recover it even when the application is restarted.

Using the File.Write() method it does not seem to work as from what I understand it can write strings or bytes. Any suggestions?

string LocalDB = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LocalDb.sqlite");

var conn = new SQLiteAsyncConnection(LocalDB);
await conn.CreateTableAsync<HumorDiary>();

var query = conn.Table<HumorDiary>();
var PagineDiario = await query.ToListAsync();
string LocalDB = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LocalDb.sqlite");

var conn = new SQLiteAsyncConnection(LocalDB);
await conn.CreateTableAsync<HumorDiary>();

var query = conn.Table<HumorDiary>();
var PagineDiario = await query.ToListAsync();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM