Windows does not show newly inserted files in a directory of a real android device /sdcard/Download/

Asked

Viewed 33 times

0

I have an Android application that I import an Sqlite file into the application to perform the queries and changes. When finished manipulating I export that same file to a user-accessible folder so I can grab 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 function "Exportardb" my directory looks like this: inserir a descrição da imagem aqui

Already on my Android device consulting by the ADB command line the directory appears like this: inserir a descrição da imagem aqui

The two images refer to the same directory, I wonder how do I update my directory on Windows as soon as I insert a new file.

Note: It is not feasible to restart the device or the machine. I tried to unplug the usb and plug again; already tried these 2 snippets of code but do not work:

SendBroadcast(new Intent(Intent.ActionMediaMounted, Android.Net.Uri.Parse("file://" + "/sdcard/Download/"))); Android.Media.MediaScannerConnection.ScanFile(this, new string[] { "/sdcard/Download/" }, null, null );

  • 1

    Try using a file manager on your device. Windows is known to present this kind of problem when managing files from a mobile device. I’ve been through this problem. I use File Manager HD Free.

  • Let me know if it works, which I put as an answer to the question :)

  • That way it worked well, it would be as an alternative solution. I would like to implement this file manager method in my application to not need to open another application, have idea how to do this?

  • 1

    Yes. There are methods that show which files exist within a given folder, such as Directory.Getfiles(folderPath). This way you can list the files present within a certain folder and then create buttons, if you wish, to delete, rename such files.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.