SD Card File Disappearing - Android Software Development

My application has a backup/restore feature that writes a csv file to a directory named after the app, in the root of the sd card. I have a user trying to move from one tablet to another. The backup feature appears to properly be creating the backup file on her SD card. When she places the SD card in her new tablet, the backup file and the directory it's stored in do not appear to be on the SD card at all. Apparently she was successful in having other data from other apps move over.
I've walked her through everything I can think, including writing a test app to verify the issue. Without a doubt, the files exist on the old device, but don't exist when installed in the new device.
I'm unsure what the original device is, but the new device is a Dell Streak 7.
Anyone seen this before? I'm leaning towards corrupt SD card, but it seems it's my burden to prove as my app is the only app she's having issues with.

The root of /sdcard is not necesarrily the SDCARD you can remove and take out.
/sdcard is usually part of the build in memory which can be accessed and used by the user.
The SDCARD you can remove is usually found at /sdcard/external_sd on Android 2.2 devices and /sdcard/sd on Android 2.1 devices.
Yes the naming is a bit confusing .

Dark3n said:
The root of /sdcard is not necesarrily the SDCARD you can remove and take out.
/sdcard is usually part of the build in memory which can be accessed and used by the user.
The SDCARD you can remove is usually found at /sdcard/external_sd on Android 2.2 devices and /sdcard/sd on Android 2.1 devices.
Yes the naming is a bit confusing .
Click to expand...
Click to collapse
That would certainly explain some things, especially if a user is moving a SD card from one device to the next.
My app creates a folder under the path returned by the Environment.getExternalStorageDirectory() function, where it creates and reads a backup file.
My documentation asks users to connect their device to a computer, mount as USB, and copy the backup file into that directory. This user is simply moving the SD card between devices. I'm wondering if there is a better method than using the getExternalStorageDirectory that I can use, so that I can have a common location on all SD cards to facilitate users moving cards between devices.

wct097 said:
My documentation asks users to connect their device to a computer, mount as USB, and copy the backup file into that directory. This user is simply moving the SD card between devices. I'm wondering if there is a better method than using the getExternalStorageDirectory that I can use, so that I can have a common location on all SD cards to facilitate users moving cards between devices.
Click to expand...
Click to collapse
Well it depends on the device what happens if they mount as usb,
if they get the internal sdcard or the external sdcard or both.
On my galaxy i9000, both the internal(/sdcard/) and external (/sdcard/external_sd) are shown when pluging it into my computer and mounting it as usb.
Environment.getExternalStorageDirectory() will always return the path of the users storage enviroment which is in usually /sdcard . Thats fine so far.
The problem is there is no function to get the external storage (/sdcard/external_sd or /sdcard/sd).
The only option i know atm, would be to probe manually if such a directory exists. You can use Build.VERSION.SDK_INT to see which android the user has and check the right directory.
Build.VERSION.SDK_INT <= 7 would mean if he has plugged in an external sdcard it would be mounted under
Environment.getExternalStorageDirectory().getAbsolutePath() + "/sd/"
Build.VERSION.SDK_INT >=8 would be
Environment.getExternalStorageDirectory().getAbsolutePath() + "/external_sd/"
You could use that and maybe a "import backup" function to check for the file on an external sdcard?

Related

standardizing sd internal and external wording

I wonder if we could could come to an understanding on language use for this device.
SDCARD = /SDCARD but is actually internal. On other devices it is of coarse external. This of coarse creates some confusion when making comon statements like "place file in root of sd"
I'm sure Asus has some reason for doing things this way. Though it seems backward to me.
Could we agree to call /SDCARD as SDI
And to call /Removable as SDE
If someone has a better idea feel free.
Regards
Ty.
I think SDI and SDE are more confusing, as in most Linux distros the SATA hard disks are labeled as sda, sdb, etc. The current naming scheme is fine as is, with removable storage available in the clearly marked "Removable" folder that gets created.
The reason for the distinction between the "sd card" and the rest of the internal storage is so that you can still read and modify the contents, because unless you root the device, the default permissions are set up so that the regular user cannot modify vital system components on the internal storage. This is has been the standard since the days of the G1, where with such little internal storage the intention was that the user would never have the ability to mess with it and risk breaking or overfilling it, and instead all of their personal data would reside on the removable SD card. Today's Android devices now possess enough storage to safely store user data internally, but the main principle remains the same, and therefore the nomenclature remains unchanged. Renaming the folder would probably break a lot of applications that depend on the ability to store data to /sdcard, so it's best not to touch it.
i guess a newbie wouldn't always get it, but the use of the nouns "sd" and "sdcard" will always refer to the external sdcard, specifically /Removable/microsd. whenever anyone wants to refer to internal storage, they would refer to it by path /sdcard exactly.
but you're right. a newbie reading it wouldn't always get it.
I don't need a signature.
finalhit said:
i guess a newbie wouldn't always get it, but the use of the nouns "sd" and "sdcard" will always refer to the external sdcard, specifically /Removable/microsd. whenever anyone wants to refer to internal storage, they would refer to it by path /sdcard exactly..
Click to expand...
Click to collapse
Totally agree - if someone tells me to put something on the SD card, to me that means unequivocally the physical SD card, not internal memory.
Regards,
Dave
Great feedback. I apreciate the clarification.
I didn't want to suggest changing the code or any other part of android. Just the reference.
When i see comments in posts that read put this file in root of sd i am left with unnecessary ambiguity. First thought would be put it on the external but after looking at possible options i quickly see there is also a location on this device called /sdcard . Ambiguous
So all i am saying is when it comes to this device, if we want to suggest putting files in root of sd we specify the location in a non ambiguous manner
IE: put file in root of sd (SDE)
Or
Put file in root of sd (/externl)
I've got 5 bucks that says 99% of people who buy this device are more noob than I.
That's all.
Ty
If someone is writing a tutorial where you would need to store files on external storage, I can't think of many instances where it would make a difference where you put the files, so long as you yourself can remember where they went. For instance, if you're told to put a .apk file on a SD card for installation later, the OS won't care where you put it, you just have to know where it is when you're looking for it later to install. The instances where it does matter whether you're storing data to /sdcard or /Removable are almost always when dealing with applications that need an extra folder outside of the internal storage for additional data, mostly for maintaining compatibility with older Android devices. Everything else like photos, videos, music, etc. can be stored anywhere within /sdcard or /Removable, and the OS can read it just the same.
When writing tutorials, you just have to be sure to make the distinction between /sdcard and /Removable, because that's a set of folders that any newbie will see and recognize when browsing through the Android file system. Simply referring to them as the internal SD and external SD can be confusing too, since that's not how they appear in the file manager. At work when troubleshooting issues with Windows 7, I deal with users every day that get tripped up if I ask them to open the Start menu or an Explorer window, because neither of them are labeled as Start or Explorer. Instead, for the Start menu I have to tell them to click on the blue orb in the lower left hand corner, and for Explorer I have to tell them to single click on Computer in the Start menu, or double click on the Computer icon on the desktop. Newbies don't know the OS, which means they don't know anything except what they can see on the screen. Anybody trying to write for newbies should always write tutorials based completely on how things appear exactly on the screen.
The joys of UNIX filesystem. It is different from windows. No need to tie thing down to physical location concepts such as disks (c:, d: , ????). I suspect if one is rooted they could alias the /sdcard to internalMemory or /InTablet.
Sent from my Transformer TF101 using Tapatalk
Would like to re-iterate this.
Just got a new device, (SGS2), it also has an internal and an external SD.
But the difference here is that the SGS2 always mounts the internal as /sdcard
Really don't like the fragmentation.
I still can't believe the ASUS sometimes mounts internal as /sdcard and sometimes external as /sdcard
It's just ****ing messy.
Ty.
Cool story bro
Sent from my Desire HD using XDA App

[Q] In simple terms, how to access/use storage on CM7 SD

I have spent the last week reading and searching the forums in an attempt to find out how to be able to access and use the empty space left on a CM7 boot sd. Some of the posts were confusing and others seemed to be targeted to those who are already very familiar with the file structures of these systems. The only paritioning experience I have is dividing a boot drive before putting on XP. I am using a Sandisk 8gb and it looks like there is about 5 gig free. Win XP is the os I am running.
So the questions I have are:
1) In simple terms, exactly what has to be done to a boot CM7 SD card to be able to use the empty space for books, mp3, etc? On the recommendations I read in different threads, I downloaded easus partition master, gnome partition editor, and minitool partition wizard. They all pretty much do the same of being able to display the 4 partitions, but what do with the programs then?
In the near future I would like to get a 16g or 32g and wouldn't want all of that space going to waste.
2) Is it possible to have it so that the NC stock boot can read the books downloaded in CM7? I have not been able to find where CM7 stores books.
Thanks to all whose work helped me get to this point. The NC is a fascinating piece of hardware.
Hey! Using the remaining storage on your SD card is quite easy. Just download and install this program on your NC. http://forum.xda-developers.com/showthread.php?t=952456 open the program and select the 4th partition to be mounted. Now when you plug your nook into the PC, the partition which holds media etc. Will be mounted you can now transfer mp3's, roms for Emulators etc.
As for #2, Your cm7 books should be on the previously mentioned partition, which is the 4th.
Sent from my ADR6300 using XDA Premium App
Imbroglio said:
I have spent the last week reading and searching the forums in an attempt to find out how to be able to access and use the empty space left on a CM7 boot sd. Some of the posts were confusing and others seemed to be targeted to those who are already very familiar with the file structures of these systems. The only paritioning experience I have is dividing a boot drive before putting on XP. I am using a Sandisk 8gb and it looks like there is about 5 gig free. Win XP is the os I am running.
Click to expand...
Click to collapse
5G sounds about right for the /sdcard partition. The rest of the partitions on an 8G card are /boot, /system, and /data. Use Root Explorer to poke around; you can tell when you jump partitions because the used/free numbers at the top will change.
/boot is not normally mounted.
The root filesystem is in-memory and is initialized from /boot/uRamdisk by default.
So the questions I have are:
1) In simple terms, exactly what has to be done to a boot CM7 SD card to be able to use the empty space for books, mp3, etc? On the recommendations I read in different threads, I downloaded easus partition master, gnome partition editor, and minitool partition wizard. They all pretty much do the same of being able to display the 4 partitions, but what do with the programs then?
In the near future I would like to get a 16g or 32g and wouldn't want all of that space going to waste.
Click to expand...
Click to collapse
The original instructions in the size-agnostic install thread detail what happens to various sizes of card; for anything above 2G /sdcard gets all the extra.
Any apps that use /sdcard for storage will use this space. App-specific config data and small databases are generally in /data unless instructed otherwise (I'm using less than 300M of my /data partition as yet). The app info or permissions will often give clues; if the permission for "read and write SD card" is requested or required, the app can or must use this space. Some apps (like BeyondPod) will always use /sdcard.
So, your space isn't wasted, it's just unused until you fill it.
2) Is it possible to have it so that the NC stock boot can read the books downloaded in CM7? I have not been able to find where CM7 stores books.
Click to expand...
Click to collapse
The CM7 SD boot cleverly uses the built-in memory for both /cache and (at least some) media storage; the "media" stock partition pre-1.2 is mounted as /emmc; I don't know how the SD boot uses the newer partitions. The NC app stores books in "/emmc/B&N Downloads/Books" and magazines in ".../Magazines". You can move your music files to "/emmc/My Files/Music" and the stock music player will automagically find them there, freeing up even more space in your SD. This partition is mounted the same for emmc-booted NCs, making an easier transition if you get to that point (it took me months to decide to go ahead and do it, and I'm happy with the choice). Other apps may look there, or can be told to look there, but since it's a new-ish Android "feature" (convention, really), it's not universal.
When you use USB mounting by plugging your charger cable into your PC's USB socket, by default the two "drives" mounted are /sdcard (named "CM7 SDCARD") and /emmc ("MyNookColor"), so you can use your PC to explore, backup, and move files back & forth to experiment. Both partitions are FAT32, so all PCs should be able to handle them. Remember to tell the PC to unmount them in software before unplugging the cable, like any thumb drive.
Thanks to all whose work helped me get to this point. The NC is a fascinating piece of hardware.
Click to expand...
Click to collapse
It is, isn't it? I haven't regretted buying one for a minute.
Thank you for posting the reply on the APP nook/cm7 file system.
Unfortunately, it still doesn't address HOW to sideload (DRAG AND DROP) books on the utilizing the empty portion of a CM7 SD card.
1. I put the SD card into an reader.
2. Windows xp detects the card.
3. I pull up windows explorer.
4. It only displays the "root" directory. Yes, I can drag and drop into the "my documents" folder but this partition only contains about 300 meg total storage.
5. It does not display the other partitions, thus I cannot drag and drop anything into the 5g partition.
Yes, I can drag and drop on the NC onboard storage, but not the CM7 SD card. Is the remaining 5 gigs only allocated for APP storage?
Now after 2 weeks searching this site and seeing numerous recommendations for software but not what to do with it or cryptic posts assuming that one already is very familiar with the android os, I am pulling my hair out over this. The only post I found that directly and simply addressed the issue requires that I reformat the SD with SDformatter to allow for full storage access but then I have install CM7 all over again.
I downloaded NookColorUMS-0.3b.apk using Opera, but that is all it did. I had to search again and it mentioned something about ADB (no idea what that is) which had to be installed. Aparently that doesn't work alone and it lead to another link to more required software - the Android SDK and then came a long list of more steps just to install that.
Hopefully, if I ever figure this out, I will write a simple to understand post that new NC CM7 people like me can understand.
Try this: unplug the charger cable from the "n"-shaped brick. Plug the cable into a USB port on your computer. Plug the other end into the NC as usual.
Tap the button(s) that pop up on the NC to allow USB mounting.
Two new drives show up on the PC. These are /emmc and /sdcard, but they'll have different names on the PC. Use Windoze Explorer to drag and drop. I might suggest /sdcard/download as a first try, but feel free to drop copies in multiple directories in order to experiment. Adobe Reader looks all over for its docs.
When you're done, click on the PC tray thing to release BOTH drives from the PC.
Poke around with your reader to find these files. Some readers might be better at looking around than others.
Let us know how you get along!
Sent from my NookColor using XDA Premium App
So once you download the NookColorUMS.apk, use the file explorer on your nook, go to the 'download' folder and click on this file. It will open up and ask you if you can install the program. Click yes and let it install.
When you are done with that, open the program and mount the partition of interest(i think its 4 as a previous poster stated). Now when you plug your nook into your computer that partition will mount. There should be 4 partitions if you are using the CM7 on SD card.
You should be able to now drag and drop files on that partition. Just make sure you unmount properly as I have run into problems if you just unplug it.
extremepizza
Imbroglio said:
Thank you for posting the reply on the APP nook/cm7 file system.
Unfortunately, it still doesn't address HOW to sideload (DRAG AND DROP) books on the utilizing the empty portion of a CM7 SD card.
1. I put the SD card into an reader.
2. Windows xp detects the card.
3. I pull up windows explorer.
4. It only displays the "root" directory. Yes, I can drag and drop into the "my documents" folder but this partition only contains about 300 meg total storage.
5. It does not display the other partitions, thus I cannot drag and drop anything into the 5g partition.
Yes, I can drag and drop on the NC onboard storage, but not the CM7 SD card. Is the remaining 5 gigs only allocated for APP storage?
Now after 2 weeks searching this site and seeing numerous recommendations for software but not what to do with it or cryptic posts assuming that one already is very familiar with the android os, I am pulling my hair out over this. The only post I found that directly and simply addressed the issue requires that I reformat the SD with SDformatter to allow for full storage access but then I have install CM7 all over again.
I downloaded NookColorUMS-0.3b.apk using Opera, but that is all it did. I had to search again and it mentioned something about ADB (no idea what that is) which had to be installed. Aparently that doesn't work alone and it lead to another link to more required software - the Android SDK and then came a long list of more steps just to install that.
Hopefully, if I ever figure this out, I will write a simple to understand post that new NC CM7 people like me can understand.
Click to expand...
Click to collapse
I am using Racks Phiremod/Honeycomb dual boot image but I don't see why this method would not work for your install. Rather than messing with mounting partitions and all that whenever I want to put something on the SD Card partition I will just plug my nook into the computer, copy and paste whatever file I need onto the nook's internal memory, and then use root explorer to cut and paste the file from the internal memory to the SD Card partition.
my emmc and sd card both show up and writable drives. I use stuff that I need faster access to in there, since the mount time is faster than the SD card.

SD card

Anyone have problems with the SD card slot I can't copy or create folders I have tryed more than one SD card I'm running stock 3.2 with no root
Sent from my LG-P925 using XDA App
There seems to be a change in the root owner of the 3.2.1 ROM for the external sd card that keeps you from being able to write to the sd card from the Thrive.
It also did this on 3.1
Sent from my LG-P925 using XDA App
File Manager HD (Honeycomb
Had same issue until I found this nice app on Android Marketplace:
File Manager HD (Honeycomb) by Rhythm Software
It is free and I was very pleased. After installing, I was able to access my sd card, create folders, then I copied my apps and pictures that were backed up on the internal memory card and pasted into folders I created on my external sd card.
App can be found on Marketplace but I did experience trouble downloading from there. However, there was a link included in the App Description so I was able to click on the link and downloaded app directly from that link.
You can find the link just after the first note that reads:
NOTE: If you have problem for downloading this application to your device from Android market, please directly download it from our website:
Name of app is:
File Manager HD (Honeycomb)
Rhythm Software
Actually I faced the same issue on my thrive, I just got a brand new 16G SDHC class6 card yesterday, and same problem the CARD couldn't be operated. Here is my thrive 3.1.04.5.0006 in china, finally I changed another card in my hand which is 2g SD c4 into slot, everything was ok, then I mounted 16g back again, surprised I can read the content of 16G card, but still can not create or paste anything. File manager HD does not work either, I feel thats the problem of permisssion
I think its Toshiba's problem maybe I should try emailing them and reporting the problem and maybe they will work up a fix
Sent from my LG-P925 using XDA App
Toshiba is well aware of the issue. If you go to the Toshiba site, many have reported it. Actually, it is not a Toshiba problem per say. Google made a change in the permissions on the sd card along with changing the mount point. If you check, many manufacturers are having this issue since HC 3.2 came out.
this seems not only issue for 3.2, 3.1 also, but mine is resovled for now, I can read/write stuff in, however I do not why it can work right now, just guess its not so stable.
I don't know why this is, but maybe it will help someone. I've been using Android devices for some time now, with the Cyanogen Mod ROMs. I just got the Thrive this past weekend and am running the stock 3.1 ROM, rooted.
I installed an SD card that has a lot of data on it from another Android device (chiefly e-books, which are organized in a "Books" folder at the root, then in subfolders by author). I found that the directory /sdcard/ had the expected folders in it (using the Toshiba File Manager), but that none of my book readers could find any of the "author" subfolders. It looked as if only the top-level directories existed and everything under them had vanished!
After doing a lot of head scratching, and moving files around, etc. I discovered that there was a directory called /sdcard/sdcard-disk0/ which contained all of the file structure that exists in the root of the physical SD card, as viewed on any other computer (desktops or another Android device).
Somehow, the Toshiba version of Android is creating what I think is a logical device (or maybe a symlink?) to the "real" SD card. I don't know why, but when I point apps to this directory instead of just /sdcard/ things start to work again.
I can help with a dirty hack to setup the external SD as the primary storage. Only for 3.2, will update this post as soon as I am at my desk.
Sent from my AT100 using Tapatalk
**EDIT This isn't a failing on toshibas part, but the nature of honeycomb itself.
however, here is how to setup your external SD card as the primary storage. I can't recommend enough to NOT take the card out while the tablet is in operation. This is a dirty method of changing up the mount points in the vold.fstab.
First it will require root on your tablet. You will need to download any file explorer that can mount the system as r/w. ES file manager, root explorer, etc etc.
Browse to /etc/ and open vold.fstab, the built in text editor in root explorer will do the trick nicely.
You need to switch the mount points of both the sd cards.
dev_mount storage /mnt/sdcard 8 /devices/platform/sdhci-tegra.3/mmc_host/mmc0
dev_mount sdcard /mnt/sdcard2 auto /devices/platform/sdhci-tegra.2/mmc_host/mmc1
will then look like.
dev_mount storage /mnt/sdcard2 8 /devices/platform/sdhci-tegra.3/mmc_host/mmc0
dev_mount sdcard /mnt/sdcard auto /devices/platform/sdhci-tegra.2/mmc_host/mmc1
noticing the 2 (external sd card) is being mounted as the thrives storage instead of an extra card.
Save the file, reboot the thrive, and enjoy installing as many apps as you want to your external sd card.
Im stock and havent had an issue with
Sent from my MB855 using XDA App

[Q] OTG Cardreader's root Location in Rootbrowser?

I got a otg-cable which has a USB port and a SD/micro SD card slot. It works fine (I can browse files when tapping on notification icon, card is empty/formatted), however, does anyone know where it's root folder is located? I can't find it with rootbrowser or root explorer.
Tried /mnt/ but there's nothing related, not even ext-sd, only the usual SDCard (internal storage), and i tried most other folders, just can't find it...
I want to backup my flashable (ROM) files from internal to my SD card without the need for a PC (which i currently don't have).
I'm using CM13.0 Snapshot on a G2-d802
anyone??
Just a thought: If the drive is indeed mounted and accessible, you could try the "df" command in Terminal Emulator to see a list of partitions and their mount points.
I have already found it. Apperantly i did not get through all folders in "/mnt". It's root-folder is located at "/mnt/media_rw/XXXX-XXXX/". I'm not sure how i messed that the first few times.
Thanks for your reply though, at least you took the time to actually make one

I can't properly write on my SD

Ok, I have had many phones and this problem is a little bit weird for me.
I'm using Poweramp as my daily driver for music. I tried deleting some songs I stored on my SD and it said my files were write protected. I then used Root Browser just to see, that most of my music and photos I have on my SD card were not located in /sdcard but in /storage/57EF-B920, a directory I never created. When I put the SD card into my PC, I can see all my files normally and r/w without any issues.
I figured I could only alter files using the stock file browser and gallery app, but why? And why are my SD card stored media files showing up in /storage/57EF-B920 instead of their actual path? Is that a security feature?
My phone is 100% stock and not rooted.
Thanks for your help!
This is how it has always been on MM. The days of /sdcard, or /storage/extSDcard for your external SD card folder are long gone with LP/KK/JB I'm afraid.
The directory for external sd is unique to your SD card. Put in another SD card, and a new directory name will get generated for it, and it alone.
The ability for an app to write to SD card is down to the app's developer. It will need to have the updated methods that MM uses. Usually, if an app can write correctly, it will prompt you to browse to the root of your external sd card the first time it attempts to access it. Even then, some apps may need extra tweaking. Titanium Backup for example requires the storage type for the external SD card to be changed to Document Storage/Provider in its settings. I used to use Nandroid Manager on my rooted S4 on CM MM, and this could never update external SD card....I had to use Root Explorer to delete/rename my TWRP backups.
You can also double check specific apps for permission through Application Manager.
Go into the specific app in application manager, click on Permissions, and make sure Storage is turned on.
Even when turned on, some apps might still fail, as I've explained.
hawkerpaul said:
This is how it has always been on MM. The days of /sdcard, or /storage/extSDcard for your external SD card folder are long gone with LP/KK/JB I'm afraid.
The directory for external sd is unique to your SD card. Put in another SD card, and a new directory name will get generated for it, and it alone.
The ability for an app to write to SD card is down to the app's developer. It will need to have the updated methods that MM uses. Usually, if an app can write correctly, it will prompt you to browse to the root of your external sd card the first time it attempts to access it. Even then, some apps may need extra tweaking. Titanium Backup for example requires the storage type for the external SD card to be changed to Document Storage/Provider in its settings. I used to use Nandroid Manager on my rooted S4 on CM MM, and this could never update external SD card....I had to use Root Explorer to delete/rename my TWRP backups.
You can also double check specific apps for permission through Application Manager.
Go into the specific app in application manager, click on Permissions, and make sure Storage is turned on.
Even when turned on, some apps might still fail, as I've explained.
Click to expand...
Click to collapse
Sorry for the late reply, but thanks for the explanation! So it's because how MM works vs how Lollipop did and Poweramp not being uptodate with that? I'll try out the permission thing and even if I fail, it's good to know why it won't work. Thank for your help!

Categories

Resources