[Nexus 6 Android Development] galaara98:
Files you SWEAR are on your "External Storage" are not...and why

I see a lot of people ask about missing files on their sdcard in Android or in Nexus 6, it is just the "main storage" area, etc. For simplicity i am going to call this location by a label "External Storage" (instead of something more precise like it's underlying mount point)

I also see people who ask about an obvious miscalculation in the amount of space or space left on their External Storage

it is my opinion that 99% of these issues stem from a feature that Android 4.2 introduces called multi-user. Originally only supposed to be used on android tablets, and hidden if the device calculated a phablet or smaller.... ROM developers and phone enthusiasts kind of strong armed Google into just letting it exist on any device (not sure when but around late Lollipop or Marshmallow)

The way Android handles Multiuser is to act like each user has a FRESH android device. All applications that are system APKs would be shared, and if a user updated a system app from the store, all user experienced the update. BUT for all User Apps, User Apps Settings, and System App SETTINGS, each user got their own version.

Many applications, including a few system apps can and do save settings to "External Storage".

[SCREENSHOT TO BE ADDED ON FUTURE EDIT]

To allow all applications, (including the same application installed *MULTIPLE TIMES by different users) to "just save their settings to 'THE' External Storage": Android devised a way for all users to have "The" External Storage, while in fact the Operating System has and is aware of many External Storages. (*it isn't, in the sense only one APK exists in /data/apps, but the Play Store will go through the motions so each user authorizes and downloads their entire set of personal apps (maybe one user is an authorize beta user and one is not, then it would have 2 apks)

[SCREENSHOT TO BE ADDED ON FUTURE EDIT]

in Android's non-rooted, factory images from vendors world.. there is no way to "screw this up"... each user gets their own space in /data/data/ and /"External Storage"/Andoid/ ..... But in a rooted world, or a "Crack Flasher" (even if not rooted) there are plenty of ways to screw this up.

The SYMPTOM is that when using anything but a very aware rooted app, you will only see the files and folders Android has ASSIGNED to you, even if you know there are other files, even if you swear you have 64 GB, but only see 24GB, even if you cry, AND even SOMETIMES if you use TWRP to wipe stuff (not "sometimes" like its random, sometimes like it depends on version, maintainer's expectation of what the default should be, and your understanding of how to override what the maintainer thinks is what you "probably" meant, and then bugs and glitches that orphan things)

the scenario i see the most, is a Custom ROM type user runs a newer version of Android... installs stuff, takes pictures.. and like to FLASH... everyso often, when the NEW Rom boots up, it decides to assign the user to the NEXT user slot, because it interprets that user 0 is already in use (or it knows this is user 0, but is not the same user 0 as the old files were for, or... ALIENS/Just because) And suddenly you feel like your storage has shrunk (if you even notice) and your files are missing (you usually notice)

[FUTURE PEPPERING OF SOME SCREENSHOTS HERE]

Convincing Android to REASSIGN you to your old files is troublesome.. a lot.

Moving your old files to where you are assigned is annoying and often confuses rooted multi-user aware applications like Titianium Backup. We saw these TONS of user posts in the past where OTA updates or Dirty Flashing made them loose "visibility" to ALL files, or crash backup and recovery processes in TWRP, Titanium, etc.

Now the above concepts are not wrong, and are not super hard.. but to an average user (even a custom ROM user) it is just too much work to walk people through them 1,000,000 times (you guys know that if i put up instructions on how to do it... i would have 2000 questions on how to AQUIRE a Root File Explorer not to mention 100x the posts on "I lost my files [MENTION=4395895]BeansTown106[/MENTION] please make a feature so I can restore them from the googlywoogies with my Atari 800, and I read on the interwebbies that other ROM can do it")

So if you find yourself in this issue, i propose a fairly straight solution.

1) if you need your files, and your are ROOTED

*find files and get them OFF Phone... means Cloud, OTG, or PC

/storage/emulated/0 or 1 or 2 or ALL of # or frankly ALL files on /storage/emulated/*

*if you cant find your files... open terminal, get root (su) and look for a name that should be there

find / -name "*TEXTHERE_NOSPACESbyQUOTESorSTAR*"

*if you still cant find your files, you're screwed... i'm sorry but unless they are worth more than a couple thousand 2017 US Dollars, then mope around, have some regret ice cream or alcohol, but move on. (if they are even extract-able... then it's more of a forensics sort of thing... if it's life or death: if you know and trust your local law enforcement, ask them about a vendor... if your in a "way too small of a town" for that.. your probably screwed.. but search online for a vendor)

This can happen in any operating system but Android seems to do it a bit more than a desktop Linux. Your files are taking space... so you have less Free Space then you expect, but the operating system forgot how they are linked (they are orphaned...again.. if the ROOT "find" command can't find them... you are gonna have to just move on... please don't assume that it's a respectable thing to ask if someone can get them back for free... just saying that is not a $20 favor)

if you need your files, but your are NOT ROOTED

Boot into Recovery

*find files and get them OFF Phone... means OTG, or PC

/storage/emulated/0 or 1 or 2 or ALL of # or frankly ALL files on /storage/emulated/*

A) Use ADB to move to PC (it's slow, ADB was not designed as a file transfer system)

B) USE TWRP advanced file interface to move to OTG (it's painful, the file copy fast, but the interface is crap for lots of files not int the same folder)

C) there is an AROMA File Explorer around that nice.

if you cant find your files, TWRP has a terminal emulator, again think of at least one file name you know should be there and hunt for the folder location with find / -name "*asdfsdafsadfdsafsdaf*" (or if you are super sure you know the precise name and extension you have my permission to leave off the wildcards... but hey why risk it)

*===*

if you dont need your files OR you are done with 1 or 2, NUKE IT

use TWRP to wipe INTERNAL STORAGE (which on a Nexus 6 which only has EMULATED External Storage is reformatting the "SDCARD")

In MY OPINION, you should actually re-do the the WHOLE THING, because there is the aching question of HOW DID IT MESS UP IN THE FIRST PLACE.

SO if was me (and i have done used this here solution to repair 10 or so of the most stubborn ROM issues i never figured out...) I would do something like:

Test and Verify ADB can talk to your phone from SOMEWHERE (i dont care) OR make sure you have ALL of the following on a OTG USB device (or a combination of a healthy ADB and OTG)

1) the latest Bootloader (please dont ponder this on a Nexus... do it damnit)

2) OPTIONALLY the Latest, OR a reasonably not outdated RADIO

I personally Prefer Recovery ZIP for these versus fastboot because i'm cool like that.

3) the LATEST TWRP (again, you can be patch and build versions behind (the 3rd or 4th numbers in a version) but stop posting why roms and gapps and su and xposed dont work etc... until after your recovery is up to date)

4) A ROM - Recovery ZIP (i highly recommend ROMs by a fellow named [MENTION=4395895]BeansTown106[/MENTION], hes reputable, smart... lots of proven projects ... seems legit)

5) a GAPPS - Recovery Zip that is a MATCH for the ROM you chose (this is actually optional... no one SAID you have to use the Google Playstore, but i assume you want to)

6) an Android Privileged Account Management Binary - Recovery ZIP (i'll let you call it superuser, supersu, the other one i cant remember, or hell write your own...OR EVEN DONT.. because ROOT is ALSO Optional, and the build in Android Privileged Account Management binary will just auto deny everything that Google or your vendor didn't send)

7) Custom Kernel if you are so inclined.... I personally am... but i am a control freak and [MENTION=4395895]BeansTown106[/MENTION] didnt make the default kernel cool enough for me... which i frankly forgive him for.

and then NUKE everything...

1) If you are going to update Bootloader and Radio via Fastboot do that first

If not then update Recovery FIRST and then using the latest Recovery, update your Bootloader and Radio

(if you have a super old TWRP then flash new one in fastboot (if you DO have one that old you deserve your troubles, just saying) OTHERWISE Boot to recovery and use TWRP ability to flash IMG file to update itself. Then reboot back to recovery

2) use TWRP, Advance WIPE and DO IT ALL (every check box).... some fairly unscientific folks like to wipe again and again... just to lower the life span of their computer chips... sometime i do to (but it's because i have attention deficit and i suddenly wonder if i actually remembered to push the OK button)

3) use ADB sideload (slower, but cool technology... if you were here before side loading existed, you also are not offended by the Term Crack Flasher) OR TWRP OTG Support to Install

ROM, GAPPS, ROOT, etc.

there are a dozen opinions on the order.. search around... ROM first, the rest is unproven scientifically what matters unless [MENTION=418212]beans[/MENTION] tell you it matters.

if you have crashes and failure and medical depression or anxiety, consider installing just the ROM, boot it up.. check it health... boot back to recovery and do one more zip, boot up see how it is going.

4) ENCRYPT YOUR DAMN PERSONAL LIFE... I could give you nice little list of my Professional Credentials, I am certified in several GIAC SANS fields, etc. but please guys (and gals).. just because no one, you know of, today, is current trying to steal your personal stuff... doesn't mean you don't care... I don't want to write another paper on why you do... but you do, it's your contacts, your dirty photos, your financial spreadsheets synced from the cloud... please just Enable Encryption the evening you go to bed after you do a Total Wipe... i don't want you in the news...you don't want the sorrow when you leave your phone for just 2 secs to talk to someone at the airport in Morocco (or you sell your phone, or your phone BRICKS, but i can still read every FREAKING THING YOU EVER PUT ON IT when i rescue it from the DUMP 10 years later... just DO IT)