After installing the SD card, format it as portable or internal storage (if your phone has Android 6.0 Marshmallow), then connect your device to your computer and move your music, media, and other files to the SD card’s free space. Android Internal storage is used to read and write data to the internal memory that store data privately. Your save files are accessible by only your app. In the below code, we have used the openFileOutput method to create a file and write data to a file.
Photos and videos are lost from internal memory of a phone more often than from SD Card. By far not every program can find a way around such an issue.
This, however, is not a merely a question of lost data. Android users have a limited set of tools they can use to recover data from internal storage of a phone.
Recovery method we are describing here can’t be called a simple one but it works.
Is it hard to recover data from Android phone internal memory?
It’s not an easy thing to access internal memory of an Android device. When you connect your phone to the computer, it is opened via Media Transfer Protocol. The content of the phone storage is connected as a separate disk and is not recognized by data recovery software.
(Whilst external SD Card can be easily accessed and scanned for deleted data).
That is the main difficulty one faces when restoring files from the internal memory. Further down the text you’ll find out how to go round this obstacle.
Steps you take to recover deleted files from phone memory
These instructions are applicable to any Android phone since you can get access to the internal memory on absolutely any of them. Another component that you need is Windows 7 or 10 (or, in principle, any OS).
Here’s the algorithm for Android internal storage recovery:
- Make a copy of the internal memory partition (as a RAW file),
- Convert RAW to VHD format,
- Connect the virtual Hard Drive to the filesystem via Disk Management,
- Scan virtual hard drive using recovery soft,
- Restore files from the copy of internal storage.
Setting up FileZilla Server
FileZilla Server is a program for creation and management of an FTP server. Without setting up the server you are unlikely to get an image of the internal storage of Android.
1. Install FileZilla Server, leave default settings as they are.
2. Run the app as Administrator.
3. Leave the name of the server unchanged.
4. Alter FileZilla General Settings:
- listen on those ports - 40
- timeout settings – specify value '0' in each case
5. In the Users section (edit – users) add a new user: click Add and type in qwer for name and pass for password.
6. In the same Users menu on the left find the tab 'Shared folders'. In it add a folder where you are going to copy the image of internal storage. Click Add and specify the address C:cygwin64000.
7. Choose the line C:cygwin64000, click Set as home dir (to get letter H on the left). Enable Read and Write options.
Setting up ADB
To set up ADB connection between your phone and PC you need the following files:
- adb.exe
- AdbWinApi.dll
- adb-windows.exe
- AdbWinUsbApi.dll
- fastboot.exe
They can be copied from the distribution kit Android SDK (size about 700MB) or downloaded in a portable format from our page:
Copy these files to the folder C:cygwin64bin.
Connecting your phone to your PC using ADB protocol
- Install USB drivers for your device (if you haven’t got them yet).
- Restart your PC.
- Enable USB debugging on your phone (for correct work of ADB).
- Now check if ADB works. The easiest way is via Windows (cmd). In the console type in:
On the list of devices you should see the code and name of your tablet or phone.
Enable USB tethering
Your mobile device needs to be connected to the computer via USB protocol using tethering. For this:
- Go to Settings & Internet, and then Hotspot & tethering (or Settings > Mobile hotspot and Tethering - USB Tethering on Samsung Galaxy).
- Enable USB tethering option.
- On computer open the command line (cmd) and type in ipconfig. Address will appear in IPv4 line.
- Remember the figure: it is going to change every time you connect your phone.
Looking for the partition with lost data
Why copying the whole internal memory to the computer (its size can reach dozens of gigabytes). Copying the partition from which files were deleted is enough.
1. To get the list of partitions in the text form, perform the following sequence of commands:
2. Next, copy the text file list_of_partitions.txt to your computer. To do this in the new console window type in:
For the moment your file with the partition list is in folder 000.
3. Figuring out the exact location of the photos, videos and other files before their deletion is not an easy task. Consider the largest partition, it is likely to be the one you’re looking for. If there is no sign of deleted files on it, examine the other internal storage partitions one by one.
Making an image of Android internal storage
1. Open a new window of the console, type in (replace this with your own data):
Keys:
- qwer – user name
- pass – password
- 40 – port number
- 192.168.42.79 – server address
- mmcblk0p27.raw – area of the internal storage where the files were located
2. Open another window in the console and type in:
where mmcblk0p27 is the name of Android internal storage partition.
3. FileZilla will start copying Android internal storage to folder 000, it’s rather time-consuming (from ten minutes up to an hour).
Converting image of the memory to VHD format
VHDTool is a program that creates VHD and VHDX virtual hard drives. You need your VHD file for mounting it into the system. It enables data recovery software to see the memory image as a separate disk, which can’t be achieved by connecting your phone using basic method.
- Download VHDTool.
- Copy VHDTool.exe file to folder 000.
- Open console utility Cygwin.bat and type in:
Here mmcblk0p27.raw is the name of your partition (rename it!).
In the end you get a VHD file, despite it having .raw extension.
Mounting the image of internal memory
For futher internal storage recovery you need to mount VHD as a virtual disk in Windows. How to do it:
- Start – Run – perform the command diskmgmt.msc. Next go to Disk Management.
- Menu Action > Attach VHD.
- As a location define [c:cygwinnexusmmcblk0p12.raw] .
- Right-click on the name to the left from the blank space and select Initialize Disk and further – GPT.
- Right-click on the blank file space – New Simple Volume.
- In the wizard click Next and leave default settings for size unchanged. Next, assign a letter to the drive (say, K). Next. Double-check that you didn’t activate the ‘Partition not allowed to be formatted’ option.
Critical! There will pop up a disk format window. DO NOT FORMAT disk at this stage. It is impossible to restore files after internal memory gets formatted!
1. Right-click on RAW space and select Format…
- File system type - FAT32
- Cluster size – by default
2. Check if the option ‘Quick format’ is enabled and click OK.
You’ll get a notification warning you that formatting this partition will remove all the data from it. Just a reminder: you selected the quick format option (double-check if so), so everything is going alright.
How to recover data from phone memory image using Recuva
- Open Piriform Recuva (you can download it here). In recovery Wizard click Next. Select All files and click Next. In the text box ‘In a specific location’ give the letter assigned to the mounted drive. Click Next.
- Tick the option 'Enable Deep Scan' – it will increase your chances to find and recover deleted data from phone memory.
- Press on 'Start' to scan the disk. Recuva works slowly in Deep Scan mode, and the whole thing can take about an hour.
- After Recuva displays scan results, select files to recover. Press on 'Recover' and specify the location you want to save selected data from the internal storage of your phone.
Questions - Answers
[Is it possible to recover overwritten photos]
I just want to ask if it’s possible to recover a deleted photos in a Samsung J7 Pro internal memory.
I purposely deleted my photos and reset my phone. Store new photos and videos until the phone storage is full and done it 7x then after that the new owner of the phone is using it. It’s almost a year now since I overwritten it, is it possible to recover my old photos doing root or the process you said?
My phone internal memory was full. So I transferred some photos to a memory card and now the majority of the photos opens as a green spot! When I went to repair it I was told that I had transferred the photos to the memory card in the wrong way and, as a result, the files were deleted. Is there a chance I can somehow fix the problem and recover deleted files from Android internal storage?!
[Lost my all photos in internal storage] Things 3 4 2 – elegant personal task management tool.
My all photos has been deleted from internal storage then I will try many of apps but failure what can I do to get my all photos and videos back please give me solution.
[making image on Android]
in your guide it says:
'find /dev/block/platform/ -name 'mmc*' -exec fdisk -l {} ; > /sdcard/list_of_partitions.txt'
if i want to get something from the internal memory, why would the text include SD CARD? also it has no SD CARD. i'm trying to find some hidden files that concealed with an app: i used the app HD SMTH which makes a folder inside the internal storage, with an extension behind it. the photos and videos are very valuable to me.
Does this article assume that the phone being accessed is a rooted device? Attempted this guide on a factory Samsung s8(not rooted) that was factory reset accidentally. Running into problems with the following commands adb shell
resulted in this response 'dreamqltesq:/ $ su'
su
resulted in this response 'su/system/bin/sh: su: not found 127ldreamqltesq:/ $'
find /dev/block/platform/ -name 'mmc*' -exec fdisk -l {} ; > /sdcard/list_of_partitions.txt
Photos disappeared I'm using Honor 6X.Since my internal storage was full, I transferred few folders from my phone's gallery to laptop.later I found the rest of my folders went missing and images are lost, including the screenshots folders.I'm sure that , I didn't delete or transfer those folders….it just went missing…what should I do , to recover my photos.
[recovering data from dead android phone's internal memory]
My samsung galaxy note 2, all of a sudden went dead after kept for charging with absolutely no sign of life. tried to put new battery and still it remains lifeless. is there a way i) i can wake up the phone ii) or at least recover deleted files from phone memory?
Recovery from internal phone memory
I have a Moto X play phone which had some important data that got deleted. I had moved the files from internal storage to SD card however it got formatted. I have never done a factory reset on my phone. Is it possible to recover the formatted data from phone internal memory? All other options to recover the data from the SD card have failed. Please suggest.
[Recovery of data from android phone internal memory]
Loved the article unfortunately recuva didn't find the files i’m looking for. The data i want resides in /data/data/org.sufficientlysecure.keychain, but the list of partitions comes back as userdata. Where should i look, do i need to download all the memory of the phone or can i just image the data portion?
Recovery of data from android phone internal memory
Hi love the guide, think there is a typo in it (nexus). Followed the guide I'm looking to restore my secret keys from openkeychain pgp, which was accidentally uninstalled. The files have the extensions .db and .sec they reside in the folders /data/data/org.sufficientlysecure.keychain/ which has also been deleted. Is there any way to make recuva (sp) find those extensions or undelete whole directories / folders?
I am using Android mobile phone. I unknowingly deleted My phone internal 'storageemulated' directory. all data paths was deleted. so i can't open or view my data all.i lost all data.do you know how to recover my all data from my phone?
Hi, this article is brilliant. It would be helpfull if you could add the info that the windows firewall might be blocking the ftp connection to the article (took me around 30min to figure out)
also how to figure out the usb tethering ipadress for the server isn't that intuitive (ipconfig -all -> Remote NDIS based Internet Sharing Device)
Regards
[Gallery photos]
Nearly all my gallery photos have disappeared. The pics saved to my SD card are still in my file folders but the internal memory pics are gone. I still have over 1/2 of memory still available can you help me. I tried one of the apps for recovery…it was no help. Thanks
The weird thing is, that when i bought my phone a year or 2 ago, the sd card worked fine. I also used to have an sd card option in the settings menu, but thats suddenly nowhere to be found. So i can't even check what's going on. I can only see the internal storage. I've tried restarting my phone with and without sd card. I've also tried reformatting the sd card, but it already had the right format. Any idea what's going on?
hello i tried to use your method on my NOT ROOTED galaxy s7 edge
everything worked until this step
Looking for the partition with lost data
Why copying the whole internal memory to the computer (its size can reach dozens of gigabytes). Copying the partition from which files were deleted is enough.
To get the list of partitions in the text form, perform the following sequence of commands:
when I write SU it tells me
Lost files from internal storage
I have deleted files from internal storage of my files in my android tab A and I lost my all photos from gallery and audio files.please help me to recover because they are important photos
This is the second post in my series about storage in Android applications. The other post is available here :
Android Format As Internal Storage
This post is about saving to a file from an Android application, which is the easiest way to store data. There are many situations where you may need to save a file : you may want to use an existing file format to create files that can be opened by the user in another application or the data is simple enough that it can be represented by a text file or a format like XML or YAML. For complex data a database may be a better option, since accessing and parsing a large file can be slow and there are no integrity checks unless you code them by hand. On the other hand, there is less overhead and it easier to work with files than debugging with the data in a database. Depending on how the user will interact (or not) with your files, you will need to decide first which kind of storage to use.
Internal storage
Each application has its own private internal storage to save files. This is the kind of storage to use if the user shouldn’t be able to modify the file from outside your application, and if other application shouldn’t be able to access those files. Since the internal storage is private to your application, the files will be deleted if your application is uninstalled. The internal storage is also where your application is installed by default, so your files will always be available. On some older or cheaper devices the internal storage is quite limited, so you need to be careful about the size of the data you save if you need to support those devices.
You should never hardcode the path to the storage directories, since the directory may changes depending on the version of the Android OS used. Also, Android 4.4 introduces the concept of multiple users : in that case, the internal and external storage depend on the user logged in and the files of the other users will be invisible. Here are some of the methods used to get the paths to the internal storage:
- android.content.Context.getFilesDir(): returns a java.io.File object representing the root directory of the internal storage for your application from the current context.
- android.content.Context.getDir(String name, Context.MODE_PRIVATE):returns a java.io.File object representing the directory name in the internal storage, creating the directory if it does not exists. The second parameter can also be used to set the directory to MODE_WORLD_READABLE or MODE_WORLD_WRITABLE so it is visible by all the other applications, but this is is risky security-wise and was deprecated in API level 17 (Android 4.2).
- android.content.Context.getCacheDir(): returns a java.io.File object representing the internal cache directory for the application. This is mean for small files (the documentation suggests no more that 1MB total) that can be deleted at any time when the system needs more storage. There is no guarantee that the cache will be cleared, so you must also clear those files manually when they are not needed anymore.
As you can see, the files are represented by the File object from the java.io namepace: there is no file object specific to the Android SDK and the standard Java APIs for reading and writing files are used. Also, there is no specific application permission to set in the Android manifest to use the internal storage since it is already private to the application.
Save File Internal Storage Android Data Recovery
External storage
In addition of the internal storage, there is an external storage space shared by all the applications that is kept when your application is uninstalled. This is the storage that is shown when using a file explorer application and when the device is plugged in your computer. It may be implemented as a SD card that can be removed or as a partition of the built-in storage in the device, so your application should be able to work even if the card is removed or changed. To check the current state of the external storage, you can call the getExternalStorageState() method.
On device with many users (starting with Android 4.4), the external storage is specific to the current user and files for other users can’t be accessed. Also, there may be more than one external storage if the device has a built-in external storage which is a partition on the internal memory and a SD card: in that case, the built-in storage is the primary external storage. Reading files from the external storage requires the READ_EXTERNAL_STORAGE permission and writing or reading files requires the WRITE_EXTERNAL_STORAGE permission.
Here are the methods you should use to call to get the directories of the primary external storage:
- android.os.Environment.getExternalStorageDirectory(): returns a java.io.File object representing the root directory of the primary external storage of the device that is shared by all applications.
- android.os.Environment.getExternalStoragePublicDirectory(): returns a java.io.File object representing a public directory for files of a particular type on the primary external storage of the device. For example, you can get the path to the public music directory by calling Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) or the public pictures directory by calling Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).
- android.content.Context.getExternalFilesDir(): returns a java.io.File representing the root directory of the primary external storage specific to your application, which is under the directory returned by getExternalStorageDirectory(). Unlike the other directories of the external storage, the files you store in that folder will be deleted when your application is uninstalled. So, if you need to store files that are only needed by your application you should use this folder. Also, there is no specific permission needed for the application to read or write to its own external storage starting with Android 4.4, but with older versions your application needs the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permission.
- android.content.Context.getExternalFilesDirs(): returns an array of java.io.File representing the root directories of all the external storage directories that can be used by your application with the primary external storage as the first directory in the array. All those directories works the same as the primary storage returned by the getExternalFilesDir() method. If the device has a built-in storage as the primary external storage and a SD card as a secondary external storage, this is the only way to get the path to the SD card. This method was introduced in Android 4.4, before that it was impossible to get the path to the secondary storage.
- android.content.Context.getExternalCacheDir(): returns a java.io.File object representing the cache of the application on the primary external storage. This cache is not visible to the user and is deleted when the application is uninstalled. There is no mechanism in the Android SDK to delete files in the cache directory, so you need to manage your cache to keep it to a reasonable maximum size. Starting with Android 4.4, the application does not need permission to access its own cache, but with older versions your application needs the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permission.
Save File Internal Storage Android Download
Example code to save to a file
Android Save File Internal Storage Tutorial
To save a file, you need to get the path to the storage you want to use which is used the same way regardless of the type of storage used since all the methods returns a java.io.File object representing the directory to use. Here is an example of using the external storage to save a text file from an Activity :
And here is an example of how to read from the file you just wrote :
A runnable code example for all the snippets is available on my GitHub at https://github.com/CindyPotvin/androidreadwritefile.