Backup and Restore Sqlite to the root

0

The thing is that in the previous version of my application, I was backing up and restoring my data stored in a sqlite database. This copy and backup was done in sdcard without any problem with File sdcard = Environment.getExternalStorageDirectory(); .

The doubt is that I have changed my mobile phone and it does not have card sdcard and I do not know how to make the copy of said database. They are bases of very small data so I do not care if it is saved directly at the root of the terminal but I do not know how to perform the backup or restore.

    
asked by user3737118 11.11.2016 в 20:45
source

1 answer

2

You do not have to worry. If it is a device without the possibility of inserting microSD cards, the call to getExternalStorageDirectory returns the route to what is called "shared storage", even if it is not external or removable:

link

  

Note: do not be confused by the word "external" here. This directory   can better be thought as media / shared storage. It is a filesystem that   can hold a relatively large amount of data and that is shared across   all applications (does not enforce permissions). Traditionally this is   an SD card, but it could also be implemented as built-in storage in   device that is distinct from the protected internal storage and can be   mounted as a filesystem on a computer.

Translation:

  

Note: Do not get confused here with the word "external". You can think of   this directory as a shared medium or storage. Is a   file system that can contain a relatively large amount   large amount of data and that is shared by all applications (not   impose permits). Traditionally it has been an SD card, but   could be implemented as internal storage different from the   internal storage protected and that could be mounted as a   file system on a computer.

To differentiate if it is of one type or another you have to use isExternalStorageRemovable : link

    
answered by 11.11.2016 / 22:16
source