Implement filesystem access on USB storage devices under Android - android

I'd like to access some files on a SDcard using a modern Android phone (e.g. Nexus 5).
Since the SDcard slot is missing on modern phones usually, I found a solution in using a USB SDcard adapter. Unfortunately Android isn't mounting the connected device automatically, but an app called "Nexus Media Importer" as well as an usb plugin for the Total commander app is able to mount it and allow access to the files.
Does anyone know how they did it? Are there some open-source libraries available maybe?

I think you should have root permissions for executing this kind of operation. However, in order to see which partitions are mounted or available on your device look inside /etc/vold.fstab.
To read /etc/vold.fstab you do not need root permissions.

I wrote such a framework as my bachelors thesis, you can find it here: https://github.com/mjdev/libaums
support_ms already mentioned it, thanks.
If you have further questions, do not hesitate to ask!

Related

External Storage Write Access for Kitkat devices

The Problem
My app supports 4.0+ and it is all about file handling. It works perfectly in all Android versions except Kitkat.
In Kitkat, my app is unable to modify or write any files in SD card. But I see various apps like,
1) Solid Explorer
2) ES File Explorer
3) CamScanner
4) UC Browser
All of these apps give write access to SD card even in Kitkat devices without even root access.
Requirements
I need to have a fully functional way to create or modify files stored in the SD card in Kitkat. I seems to have troubles a lot of users and a proper solution will help many developers like me.
Yeah I came across that problem as well. After a lot of reading across the web the solution is to write only in your app folder (Ex: /sdcard/Android/data/packagename).
About those apps, on my s4 mini, es explorer cannot delete from external sdcard, so I think is different from device to device.
If the devices is routed change the permissions to gain write access anywhere on the sdcard.

How to read/write external USB storage on Android?

I am currently making an app that needs to be able to read from and write to a USB flash drive connected via a USB OTG adapter. Is there an easy way to access this storage via standard Java.io.File APIs? This app is only going to be run on a rooted Motorola Xoom running Android 4.2.2. Any suggestions would be appreciated.
USB Drives get mounted to your device just like an SDCard does essentially*.
The mount path usually resides at:
/storage/usb0/
I have not used this on many devices other then my Droid running CyanogenMod, your device may very. You can smiply use a file manager to explore this path. The directories will still exist even if there is no mount path, so you will be able to determine the path.

Make device SD Card windows bootable by an android app

It may seem strange, but I wonder is an android app able to make the SD Card inside the device windows bootable? I thought of making the SD bootable and write ultimatebootcd to it. I did it through windows, but it would be so great if android can do it!
To make the SD card bootable, you have to modify the boot sector of the card. This can not be done from a standard Android application. If the Android device is rooted, it can almost certainly be done from a native Linux program, or an NDK program.
If the device is not rooted, you can probably not do what you want. As Chris Stratton commented, if the card is already made bootable, you could probably then change for instance what OS is booted up and how.
Say, there is startup code which loads and boots an OS, then you can change the configuration file for the bootloader. A starter: http://www.syslinux.org/wiki/index.php/Boot_an_Iso_image
I used Rufus and installed a syslynux on the SdCard from a PC running window 10.then I put the card back into the Moto phone. It's receiving files that I have moved from the internal storage to the card how ever I have not a chance to find out whether they Will open up In the PC or not.

Find SD card volume label on Android

Is it possible to find out volume label of SD card inserted into Android device?
I understand that Android is designed to have just one "external storage" (as returned by Environment.getExternalStorageDirectory()), but there are quite a few devices in the wild that have internal flash as "external storage" and an SD card mounted under that or even wilder combinations (see this other question). It is possible to enumerate these additional devices by reading /proc/mounts, but we need something to identify them to the user. Is there any chance to get to their volume labels?
I checked that Linux vfat driver ignores the volume label dentry altogether and that blkid from util-linux reads the vfat itself. I also checked that, at least on device I have, the block device of the SD card has mode 660 and owner root.root, so I can't do that. So basically it boils down to whether there is any utility that could read it available.
I have found a solution.
The easiest solution is to build busybox and use it like this:
busybox blkid
Complicated solution is to find blkid for Android and find what you need in its source code (blkid_dev_devname function).
i don't know how it works exactly in android, but in linux i have kernel message about mounting sd-card, where volume name specified. You can try dmesg and cat /sys/devices/mmc... (or somethong like that)
Try to parse output of blkid command. It works for me, but I'm not sure if it is a firmware depended feature or not. I got permission denied with this command on AVD.
I don't know if this can help you: if you use the DDMS you can see the folders of the system. In my case, I found the sd card in: /mnt/media_rw.
You can get more information here and here
I hope it helps.

Possible to write files from Windows application directly to Android SD card?

I'm looking for a way to write a file from a Windows application to an Android device SD card over a USB connection. To do this, I will need to obtain the drive letter of the SD card, and it's mount point. My Windows application is written in C++, so I'm most hoping for a solution in C++. If not possible, perhaps there is a Java solution which can then be placed in a C++ wrapper to be called by my application's code.
I've searched around and come up with a few ideas but nothing seems to work yet. First, I came across Google's documentation on a method,Environment.getExternalStorageDirectory(), but my assumption is that since this is part of the Android SDK, it is only usable from an application residing on an Android device. Secondly, I came across some functions in Windows' native API (WinBase.h primarily), which provides a way of locating all drives and their corresponding letters, but even if I can get this information, I don't know how to determine which of these is the connected Android device's SD card.
Any help is appreciated!
I'm not a windows application expert but if you can use system calls in your C++ program to call adb.exe, then you can execute adb commands directly to the device.
For example if you can execute "adb.exe devices" you can get a list of all android devices currently attached to the computer. From there, you can use any adb commands to push files onto the device.
More information on the adb commands here: ADB wiki
What you're looking for is probably doing an adb devices in combination with adb push <your file> /sdcard/<file on sdcard>
Good luck!

Categories

Resources