在Visual Studio和模拟器中使用MonoDroid,我试图将资产“db.sqlite”从assets文件夹复制到SD卡,以便我可以打开数据库进行读/写 .
当我运行应用程序时,它就会死掉 . MonoDroid没有给我任何调试信息 .
string destPath = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.Personal), "db.sqlite");
if (!File.Exists(destPath))
using (Stream stream = Assets.Open("db.sqlite"))
{
stream.CopyTo(File.Create(destPath));
stream.Close();
}
3 回答
检查Android调试日志:
http://android.xamarin.com/Documentation/Guides/Android_Debug_Log
尝试使用数据库文件.mp3扩展名保存文件,然后使用以下脚本将其复制到SD卡
对我有用的代码(它递归复制文件或目录和所有子目录):
用法:
copy(path_relative_to_assets_root);