I have an Android application that I import a SQLite file into the application to perform queries and changes. When I finish manipulating I export that same file to a folder accessible to the user so that I can get the same file and use it.
ANDROID VERSION: 4.4.4
I have this function to import the file
public void ImportarDB()
{
try
{
string script1 = "cp /sdcard/Download/file.db /data/data/br.com.app.inventario/file.db";
Java.Lang.Runtime.GetRuntime().Exec(script1);
script1 = "rm /sdcard/Download/file.db";
Java.Lang.Runtime.GetRuntime().Exec(script1);
}
catch (Exception)
{
}
}
And this one to export
public void ExportarDB()
{
try
{
string script1 = "cp /data/data/br.com.app.inventario/file.db /sdcard/Download/file.db";
Java.Lang.Runtime.GetRuntime().Exec(script1);
}
catch (Exception)
{
}
}
After executing the "ExportDB" function, my directory looks like this:
OnmyAndroiddevice,theADBcommandlinelookslikethis:
Thetwoimagesrefertothesamedirectory,IwouldliketoknowhowtoupdatemydirectoryinWindowsassoonasIinsertanewfile.
Note:Itisnotpossibletorestartthemachineorthemachine.Ialreadytriedtounplugtheusbandplugitagain;I'vetriedthese2codesnippetsbuttheydonotwork:
SendBroadcast(newIntent(Intent.ActionMediaMounted,Android.Net.Uri.Parse("file://" + "/sdcard/Download/")));
Android.Media.MediaScannerConnection.ScanFile(this, new string[] { "/sdcard/Download/" }, null, null );