How android application detects two SD CARDS in a device - android

If android device has two SD CARDS then how the application detects both SD CARDS in android.For example the device has "left user sdcard" & "right user sdcard". Then How android supports programmatically
Thanks , Shiv

There will be just two mount points for two cards in file system. It depends on firmware. The device manufacturer is most likely to define. Though, I have never ever come across any such Android device (actually, no hand held device so far)
Probable mapping:
Your internal flash memory should be: /mnt/sdcard/
External cards: /mnt/sdcard/sdcard1 and /mnt/sdcard/sdcard2 (or /mnt/sdcard/sdc1 and /mnt/sdcard/sdc2)

Related

Android Internal Storage advice

I am developing an app for University.
I have bought a Nexus 7 google tablet for the task (I wanted a tablet anyway :P)
I need to convert data I record on the app onto a text file that can be moved onto a PC.. Now, from what I can tell android has high security on 'Internal Storage' which is the only type of storage the Nexus 7 has, and I cant seem to be able to write a text file to a folder or anything.. and I can't even find the app's data folder on the windows explorer so I presume its hidden..
It appears its possible with 'External Storage' such as an SD card but the Nexus 7 does not have an SD card slot..
what should I do? Is it possible to be done on the Nexus 7?
All Android devices have "external storage" regardless whether or not they have SD card support (http://developer.android.com/guide/topics/data/data-storage.html#filesExternal). The naming is unfortunately misleading.
If you save your data to app's default external storage, you can access them on a PC in /Android/Data/[your app's package name]/files

Enable the SD Card while USB Debugging?

I am developing a phone app and I'm testing it with my Droid RAZR with OS version 4.1.2
I need the phone to be able to use its SD card, and prevent the computer from using the USB connection as a "mass storage" connection, which causes it to take over the SD card (it can only be mounted to either my phone or the computer, not both).
You used to be able to connect to the computer in "Charge Only" mode, which would keep the SD card active with the phone, but that no longer seems to be an option. There is only Mass Storage (computer uses SD card), Media Device (same story), and Camera (same there too).
Is there another option? Perhaps some way to disable the mass storage from the PC's side but still retain the USB Debugging?
Take a look at this thread here. As stated there:
Next, enable USB debugging by checking the “USB Debugging” item.
Finally – and this is the most oddball – you need to go back a screen,
to Settings, and click on the Storage item. Up in the upper right of
the screen are three tiny squares which represent the Jelly Bean way
of doing a context menu. Click that, and a small “USB Computer
Connection” item will appear. Click that. You’re taken to a new
screen with two “Connect As” options.
Check “Camera”. Yes, because USB debugging requires the use of a
camera (no, not really). It’s just a requirement. Something about
the communication protocol or file transfer encoding or something. I
don’t make this stuff up.

Fetching Files from SD card and USB to different folders when using getExternalStorage()

Is it possible to sort the files detected from usb and SD Card seperately?.I mean I fornd that using getExternalStorage,we are able to detect all external devices connected to Android device which includes both SD card and USB.
I would like to seperate the files that are detected to 2 seperate folders(Now the files from SD card and USB are detected into same folder)..ie USB files seperately and SD card files seperately.
How to do it?Kindly help
You have to code in the logic to determine if the "external storage" is really external storage. Different devices use a different name - very stupid I agree. In Google's API doc's I'm pretty sure they mention that getExternalStorage() is not guaranteed to grab the external storage as this is manufacturer and device specific.
Knowing this pitfall may assist you in a solution.

Terminology for SD Card Status

We've developed an Android program that relies on access to a particular directory on the SD card. Our program detects whether the SD card is available to the phone, and displays an error message to the user if it's not. The most common use case that will trigger this error is having the device plugged into a computer and having the SD card mounted to the computer.
We're working on the error message, which will instruct the user to make sure the SD card is available to the phone.
Unfortunately, it appears that each phone manufacturer has their own terminology for whether the SD card is available to the phone and how to mount/unmount it. For example, (some?) Samsung devices display a screen with a Mount/Unmount button. The HTC Thunderbolt has a menu one of whose options is "Charge Only". Motorola devices seem split between the Samsung-like behavior and the HTC Thunderbolt-like behavior. The XOOM is it's whole own contraption.
So, two questions:
Is there a common correct terminology that will communicate to the user that they should make the SD card available to the device instead of available to the computer?
If there's not a good common terminology, is there a way to determine what sort of device we're running on and tailor our error message to the particular device's terminology?
"Please remove all usb peripherals (exc chargers) for this app to work"?
NB. (when its mounted but they think its just a charger they will eventually remove it to see if it works anyway!)
Otherwise:
http://developer.android.com/reference/android/os/Build.html
Check out BRAND or MANUFACTURER or a combination of them plus others (MODEL == 'XOOM' maybe?)
if("Motorola".equals(android.os.Build.MANUFACTURER)){ // or .contains or .starts with etc
// Do stuff
}
You may want to do some testing as it may return "Mtrla" or "MotorolaChina" etc..

How to safely remove SD card programmatically on Android

I want to let the user safely remove the SD card in my program, but it seems the Android 2.2 public API does not provide a way to do this. Does anyone know what's a proper way to do it?
You need to take the user to the device's built-in Settings. I think this will work.
Intent i = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS);
startActivity(i);
Unmounting the SD card is one of those actions which could be used maliciously if it wasn't under full user control. If it could be done purely in software (without user intervention) then code could disrupt other apps running on the device.
Indeed on the Logitech Revue (the Google TV companion box) that Intent call launches the Storage control panel which gives user access to the Unmount command for safe removal. If you just pull the USB device out on that unit it is experienced as an Unsafe/unexpected removal and your card could be left in proverbial disarray if treated that way. Thanks for the hint, very useful.
The Revue by the way have an unusual arrangement with the /sdcard unit built in,
so if you plug in an external SD card via USB adapter or use some USB stick it will show up under /mnt/ as a name beginning with "usb" and some number. So you have three storage areas on that unit, internal, the built in "sdcard" and USB ports where drives will mount when inserted.
I haven't earned enough points yet to be allowed to include a snapshot of how the panel looks.

Categories

Resources