// AgendamentoViewModel.cs
private void SalvarAgendamentoBD() {
using (var conexao = DependencyService.Get<ISQLite>().PegarConexao()) {
AgendamentoDAO dao = new AgendamentoDAO(conexao);
dao.SalvarAgendamento(new Agendamento(Nome, Fone, Email, Modelo, Preco));
}
}
// SQLiteAndroid.cs
public SQLiteConnection PegarConexao() {
var caminhoBD = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, nomeArquivoBD);
return new SQLite.SQLiteConnection(caminhoBD);
}
segue abaixo as exceções:
Unhandled Exception: SQLite.SQLiteException: <Timeout exceeded getting exception details> ocorreu
Unhandled Exception: SQLite.SQLiteException: Could not open database file: /storage/emulated/0/Agendamento.db3 (CannotOpen) ocorreu
segue abaixo log:
06-09 19:16:27.888 E/mono (16840): Unhandled Exception:
06-09 19:16:27.888 E/mono (16840): SQLite.SQLiteException: Could not open database file: /storage/emulated/0/Agendamento.db3 (CannotOpen)
06-09 19:16:27.888 E/mono (16840): at SQLite.SQLiteConnection..ctor (System.String databasePath, SQLite.SQLiteOpenFlags openFlags, System.Boolean storeDateTimeAsTicks, System.Object key) [0x00082] in <eaa146ee868043e287f5507c8701ad9e>:0
06-09 19:16:27.888 E/mono (16840): at SQLite.SQLiteConnection..ctor (System.String databasePath, System.Boolean storeDateTimeAsTicks, System.Object key) [0x00000] in <eaa146ee868043e287f5507c8701ad9e>:0
06-09 19:16:27.888 E/mono (16840): at TestDrive.Droid.SQLiteAndroid.PegarConexao () [0x00016] in C:\Users\gustavo\source\repos\modulo3\TestDrive\TestDrive.Droid\SQLiteAndroid.cs:26
06-09 19:16:27.888 E/mono (16840): at TestDrive.ViewModels.AgendamentoViewModel.SalvarAgendamentoBD () [0x00001] in C:\Users\gustavo\source\repos\modulo3\TestDrive\TestDrive.Aula3\ViewModels\AgendamentoViewModel.cs:126
06-09 19:16:27.888 E/mono (16840): at TestDrive.ViewModels.AgendamentoViewModel+<SalvarAgendamento>d__31.MoveNext () [0x0018b] in C:\Users\gustavo\source\repos\modulo3\TestDrive\TestDrive.Aula3\ViewModels\AgendamentoViewModel.cs:117
06-09 19:16:27.888 E/mono (16840): --- End of stack trace from previous location where exception was thrown ---
06-09 19:16:27.888 E/mono (16840): at (wrapper dynamic-method) System.Object.27(intptr,intptr)
06-09 19:16:27.888 E/mono (16840): at (wrapper native-to-managed) System.Object.27(intptr,intptr)
06-09 19:16:27.889 E/mono-rt (16840): [ERROR] FATAL UNHANDLED EXCEPTION: SQLite.SQLiteException: Could not open database file: /storage/emulated/0/Agendamento.db3 (CannotOpen)
06-09 19:16:27.889 E/mono-rt (16840): at SQLite.SQLiteConnection..ctor (System.String databasePath, SQLite.SQLiteOpenFlags openFlags, System.Boolean storeDateTimeAsTicks, System.Object key) [0x00082] in <eaa146ee868043e287f5507c8701ad9e>:0
06-09 19:16:27.889 E/mono-rt (16840): at SQLite.SQLiteConnection..ctor (System.String databasePath, System.Boolean storeDateTimeAsTicks, System.Object key) [0x00000] in <eaa146ee868043e287f5507c8701ad9e>:0
06-09 19:16:27.889 E/mono-rt (16840): at TestDrive.Droid.SQLiteAndroid.PegarConexao () [0x00016] in C:\Users\gustavo\source\repos\modulo3\TestDrive\TestDrive.Droid\SQLiteAndroid.cs:26
06-09 19:16:27.889 E/mono-rt (16840): at TestDrive.ViewModels.AgendamentoViewModel.SalvarAgendamentoBD () [0x00001] in C:\Users\gustavo\source\repos\modulo3\TestDrive\TestDrive.Aula3\ViewModels\AgendamentoViewModel.cs:126
06-09 19:16:27.889 E/mono-rt (16840): at TestDrive.ViewModels.AgendamentoViewModel+<SalvarAgendamento>d__31.MoveNext () [0x0018b] in C:\Users\gustavo\source\repos\modulo3\TestDrive\TestDrive.Aula3\ViewModels\AgendamentoViewModel.cs:117
06-09 19:16:27.889 E/mono-rt (16840): --- End of stack trace from previous location where exception was thrown ---
06-09 19:16:27.889 E/mono-rt (16840): at (wrapper dynamic-method) System.Object.27(intptr,intptr)
06-09 19:16:27.889 E/mono-rt (16840): at (wrapper native-to-managed) System.Object.27(intptr,intptr)
06-09 19:16:27.898 D/ (16840): HostConnection::get() New Host Connection established 0x8dad6940, tid 16840