2

I've done a procedure to backup/restore user's DB into an external SD card. Theoretically it works fine, the file is being copied and restored every time I launch it.

What I don't understand is WHERE that file is copied. According to the message I receive when I do my backup, the archive is put inside "\storage\emulated\0" folder.

But .. Where is that folder? According to the documentation that should be my SD folder but actually, watching on my phone, that directory is INSIDE my phone's internal memory and that file is not present inside my SD card.

I even tried this path to understand where Android sees my SD :

     String state = Environment.getExternalStorageState();
     File sdPath = Enviroment.getExternalStorageDirectory();



*** The results are:***
- state : Mounted (so the SD can be read and written)
- sdPath: \storage\emulated\0

So, once again, the SD seems ok, can be written... but why It keeps writing on my internal phone's memory?

YoungHobbit
  • 13,254
  • 9
  • 50
  • 73

3 Answers3

0

The path to SD Card is usually \storage\extSdCard\YourDir

You can get it By :

String sdCardPath= System.getenv("SECONDARY_STORAGE");
ikken
  • 563
  • 4
  • 15
0

Android take Mobile Storage as External Storage and Storage where application data stored as Internal Storage.

Devices which does not provide internal storage

MUHAMMAD SOBAN
  • 403
  • 8
  • 20
0

If you write code like this then you can see your db files in your mobile inside sdcard

public DataBaseHandler(Context context) 
    {
        super(context,"/sdcard/Folder/"+DATABASE_NAME,null,DATABASE_VERSION);
    }

One folder will be created inside your mobile sdcard, you can check. If it is just a file then change the extension with .db. After that copy it to desktop and open the sqlite browser, then click on open database, open this file and in sqlite browser you can see one option "browse". Now you can see your data is inserted or not. Enjoy !

Däñish Shärmà
  • 2,891
  • 2
  • 25
  • 43