Hey all,
I'm kinda stuck on something and was hoping someone could point me in the right direction. I have an app that is using the aFileChooser module. Basically I have the chooser come up and the user will select a file from either internal, external or OTG storage. with aFileChooser if they select a file from the internal sd card it works. If they select a file from either External USB Storage or External SD card it does not. I have noticed in the getPath method in FileUtils in aFileChooser it has this condition:
Code:
if ("primary".equalsIgnoreCase(type)) {
Log.i ("PRIMARY", Environment.getExternalStorageDirectory() + "/" + split[1]);
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
Now when the user selects a file from the internal card this condition is satisfied here is the uri:
Uri =content://com.android.externalstorage.documents/document/primary%3Amyfile.txt
So it will return the correct path /storage/emulated/0/myfile.txt
Now when I select a file from the external card this is the Uri:
Uri = content://com.android.externalstorage.documents/document/3935-6562%3Amyfile.txt
Same for the OTG storage the uri is
Uri = content://com.android.externalstorage.documents/document/2841-32E9%3Amyfile.txt
So there are no conditions to deal with if type = 3935-6562 or 2841-32E9 But is this the same identifier across all devices or will these change depending on device? I don't want to hardcode for these and have them be different on device and then how would I get the correct path even if I did hard code the numbers?
I just want the chooser to return the correct path depending on what stoage they picked
on my device that's /storage/sdcard1 and /storage/usbdisk but I know this will be different on different devices so I don't really want to hard code anything.
Any help would be appreciated..
You probably haven't declared permission for read/write to external storage in your manifest <uses permission EXTERNALSTORAGE>
http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE
Related
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?
One issue I've had is larger games that place files on the SD card would fill the internal sd card's space up fairly quickly, and they would never have an option to place these files in another location, so I edited the ect/vold.fstab to switch the mount points for sdcard and external_sd so that my larger microsd card could be my primary storage and i could use the internal for other odd things that i change less often, I've yet to run across any issues, although I haven't tried to use the built in format options since doing this. If anyone else wants to try this, here is what I changed to get this to work
via root explorer or another method, find the "vold.fstab" file under the "ect" and make a backup of it, then pick open in text editor in root explorer and change the following sections that are in bold to what i have them shown as
for GB
# internal sdcard
{
ums_path = /sys/devices/platform/usb_mass_storage/lun0/file
asec = enable
discard = enable
format_option = -r 2236
}
dev_mount sdcard1 /mnt/sdcard/external_sd 11 /devices/platform/s3c-mshci.0/mmc_host/mmc0/mmc0
# external sdcard
{
ums_path = /sys/devices/platform/usb_mass_storage/lun1/file
asec = disable
}
dev_mount sdcard /mnt/sdcard auto /devices/platform/s3c-sdhci.2/mmc_host/mmc1
Click to expand...
Click to collapse
save and reboot
for ICS (samsung based)
# internal sdcard
{
storage_struct = cover, "/mnt/sdcard/external_sd","/mnt/sdcard/usbStorage"
ums_sys_path = /sys/class/android_usb/f_mass_storage/lun0/file
discard = enable
}
dev_mount sdcard /mnt/sdcard auto /devices/platform/s3c-sdhci.2/mmc_host/mmc1
# external sdcard
{
ums_sys_path = /sys/class/android_usb/f_mass_storage/lun1/file
android_secure_containers = enable
}
dev_mount sdcard1 /mnt/sdcard/external_sd 11 /devices/platform/dw_mmc/mmc_host/mmc0/mmc0 encryptable_nonremovable
Click to expand...
Click to collapse
I've attached to this post a copy of my vold.fstab for ICS, i've tested it and it does allow applications to be moved to sd and my 64gig card works just fine as /mnt/sdcard. Best to still backup your original file before trying it and make sure you match the permissions of the original. It did require a few changes to make it function under ICS compared to how it was done in GB. Do not use the ICS copy for GB.
Thanks ciphray.
I have been looking for this and appreciate your help.
Will certainly try now.
Just one word "AMAZING"
This is awesome! Not useful as i have 16gb external card, but will do when i upgrade
Sent from my GT-N7000 using XDA App
I did the tutorial and now show me the sd space is unavailable and all the space of the sd is in usb storage,how I can do to show me the two spaces at the same time
the lines must be exact so likely there's a space you're not seeing or a letter missed, I've attached a copy of mine in a 7zip file, see if this helps, make sure the permissions match your old file
edit: updated file attachment for move to sd function
I dont think this is getting the attention is deserves, so ... bump
I may just try this before the day is out
Thanks for this tip.
I've found an issues with move apps from the 2GB storage partition to SD card (now the removabe one) after doing the swap. The phone generate an error of "SD card is full".
Any idea on how to solve this problem?
Cheers
Bigmille said:
Thanks for this tip.
I've found an issues with move apps from the 2GB storage partition to SD card (now the removabe one) after doing the swap. The phone generate an error of "SD card is full".
Any idea on how to solve this problem?
Cheers
Click to expand...
Click to collapse
edited first post, the asec disable/enable needed to be reversed, this should fix the move to sd coming back as full, just change those 2 save and reboot and that should take care of it
sorry for asking this in note thread....but i want it on my galaxy s2......
can i do the same for it to swapping the memory paths.....???????????
thanks for sharing. so i just install apps and it will be in sd card?
the titanium move apps to sd is external or sd?
this might work for a galaxy s2 with the same paths/partitions however as i do not have a galaxy s2 i cannot test this, at the worst you can just revert to the original file, as long as you made a backup if it doesn't work. it'd definitely be doable either way by following the same overall method of reversing the 2 mount points
as for the apps to sd thing, this doesn't enable any apps to be moved to the sd card that weren't already movable before, this simply makes it so they would go to the sd card instead of the internal 12gb partition, this is mostly useful for games that store files in a fixed path like mnt\sdcard or mnt\sdcard\android such as larger games
Be warned though, the internal space if probably much faster than your SD card. It certainly is in my case, and I don't see myself wearing out the chip in the next few years.
I have SG-N...
If I do this, will the device going to be faster or it's just about more storage space?
Just more storage space. The internal SD is a great design as the average read and write is about 20 ~ 30 mb/s. Run an ANTUTU test and you'll see what i mean.
If you prefer performance, this is definitely the way to go. The external SD is better suited for recording videos, storage pictures, and movies on the go.
Would it be possible to update this hack for the ICS build?
I tried the same with ICS "vold.fstab" but only the external SD card will mount, not the internal SD card.
Many thanks
Still, doesn't work for apps storage space (The 2GB allowed for apps to be installed on device)!
If this way can be extended to cover that instead of Move2SD or Link2SD, it would be great!
Sent from my GT-I9220 using xda premium
updated original post with ICS support
AT&T LTE White Samsung Galaxy Note
OK, so I followed this step by step & now my external SD is unavailable & won't mount & the internal USB storage is unavailable as well. Restarted a few times to no avail. Because the external card won't mount. I can't copy the original file back over. I typed it in, per the original file & that didn't help either, any ideas?
if you edited it with root explorer then it should have also created a backup called vold.fstab.bak unless you edited it more than one time in which case that file would have been overwritten with your second edit, you could try going into cwm and mounting the storage via usb from in there to get to your backup on your card(this doesn't effect your sd card while not booted into android), and then put it in a dropbox account or email it to yourself, and then save that file to an accesible area of your 2gb internal storage, and then copy it from there, did you use the correct copy? ie GB ver on GB or ICS ver on ICS? they changed a few things so the 2 are not interchangeable, but as long as you have it exactly right including spaces then there shouldn't be any way this wouldn't work on any of the Samsung based roms
I am srsly pissed off with this internal storage used as external....
What can I do in order to somehow bind the two internals in order to use my 32gb sd card as external?
Berat1337 said:
I am srsly pissed off with this internal storage used as external....
What can I do in order to somehow bind the two internals in order to use my 32gb sd card as external?
Click to expand...
Click to collapse
You can use directorybind, an app http://forum.xda-developers.com/showthread.php?t=1410262, but doesn't work with google music. For that problem i used an modded version, google music+ http://forum.xda-developers.com/showthread.php?t=2140756 , where you can change the storagelocation in-app.
robhaans said:
You can use directorybind, an app http://forum.xda-developers.com/showthread.php?t=1410262, but doesn't work with google music. For that problem i used an modded version, google music+ http://forum.xda-developers.com/showthread.php?t=2140756 , where you can change the storagelocation in-app.
Click to expand...
Click to collapse
Tried this app before but i failed everytime.... what EXACTLY should I do in order to bind these directories...?
On source data path goes the /sdcard thing and on mount path the target location ?
I wanna bind my internal sd to 32gb ext. card...
Berat1337 said:
Tried this app before but i failed everytime.... what EXACTLY should I do in order to bind these directories...?
On source data path goes the /sdcard thing and on mount path the target location ?
I wanna bind my internal sd to 32gb ext. card...
Click to expand...
Click to collapse
You can read it on the thread, but in short how to do it: make a folder on your external sd, for example DCIM (where photos are stored), then open directory bind. Tap settings button, then add new entry. Tap and hold source, then browse to the new folder DCIM on your external sd (real one), and tap select. Then tap and hold target source and browse to the old DCIM-folder and tap select. You can also transfer existing files, check that. Then tap "add".
On settings, check Bind on boot.
You will need to be rooted first btw...
robhaans said:
You can read it on the thread, but in short how to do it: make a folder on your external sd, for example DCIM (where photos are stored), then open directory bind. Tap settings button, then add new entry. Tap and hold source, then browse to the new folder DCIM on your external sd (real one), and tap select. Then tap and hold target source and browse to the old DCIM-folder and tap select. You can also transfer existing files, check that. Then tap "add".
On settings, check Bind on boot.
You will need to be rooted first btw...
Click to expand...
Click to collapse
ye I am rooted and fully unlocked. I have the v20d version, thank you for the detailed info, helped alot!
H!
I am still trying/desperately trying to fix my Samsung Galaxy S4 problem on my external SD Card. (SD card blank or has unsupported file system)
I have tried everything that I can find on the internet and on XDA. I dont think I have a faulty external SD card slot becuase when I go to recovery mode and the mount my SD card using recovery my PC can see my SD card and format it even but it cant see mount it and the problem started when I first rooted my phone and installed a custom Rom. Another thing is that other phones (S4, Blackbeery z10, Note 2) can see and use my SD card just not my phone.
One thing I want to try after reading and trying a bunch of fixes is that maybe my vold.fstab has been edited.
Can somebody be my hero and post a regular or unedited vold.fstab and I can try to copy it on my phone?
Any help would be greatly appriciated.
Or maybe you guys can use my vold instead?
Maybe you can see something wrong with my vold?
#######################
## Regular device mount
##
## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
## label - Label for the volume
## mount_point - Where the volume will be mounted
## part - Partition # (1 based), or 'auto' for first usable partition.
## <sysfs_path> - List of sysfs paths to source devices
######################
#storage_struct = series, "/mnt/sdcard/extStorages"
#storage_struct = parallel
{
supported_exfat = yes
}
dev_mount sdcard /storage/extSdCard auto /devices/platform/msm_sdcc.4/mmc_host/mmc2/ /devices/platform/msm_sdcc.2/mmc_host/mmc2/
#usb host device
{
media_type = usb
supported_exfat = yes
}
dev_mount sda /storage/UsbDriveA auto /devices/platform/msm_hsusb_host/usb
#usb host device
{
media_type = usb
supported_exfat = yes
}
dev_mount sdb /storage/UsbDriveB auto /devices/platform/msm_hsusb_host/usb
#usb host device
{
media_type = usb
supported_exfat = yes
}
dev_mount sdc /storage/UsbDriveC auto /devices/platform/msm_hsusb_host/usb
#usb host device
{
media_type = usb
supported_exfat = yes
}
dev_mount sdd /storage/UsbDriveD auto /devices/platform/msm_hsusb_host/usb
#usb host device
{
media_type = usb
supported_exfat = yes
}
dev_mount sde /storage/UsbDriveE auto /devices/platform/msm_hsusb_host/usb
#usb host device
{
media_type = usb
supported_exfat = yes
}
dev_mount sdf /storage/UsbDriveF auto /devices/platform/msm_hsusb_host/usb
#EOF
carlo06 said:
H!
I am still trying/desperately trying to fix my Samsung Galaxy S4 problem on my external SD Card. (SD card blank or has unsupported file system)
I have tried everything that I can find on the internet and on XDA. I dont think I have a faulty external SD card slot becuase when I go to recovery mode and the mount my SD card using recovery my PC can see my SD card and format it even but it cant see mount it and the problem started when I first rooted my phone and installed a custom Rom. Another thing is that other phones (S4, Blackbeery z10, Note 2) can see and use my SD card just not my phone.
One thing I want to try after reading and trying a bunch of fixes is that maybe my vold.fstab has been edited.
Can somebody be my hero and post a regular or unedited vold.fstab and I can try to copy it on my phone?
Any help would be greatly appriciated.
Click to expand...
Click to collapse
what is your variant?? 9500,9505...?
samersh72 said:
what is your variant?? 9500,9505...?
Click to expand...
Click to collapse
ohhh sorry forgot to include that, I am using 9505!
hope you can help!
thanks for the reply!
carlo06 said:
ohhh sorry forgot to include that, I am using 9505!
hope you can help!
thanks for the reply!
Click to expand...
Click to collapse
here you go
thanks!!! sadly though we have the same vlod.
well back to the drawing board then. Anything you can add that I can try?
I have tried reformat to every kind of file system, I have tried all roms and stock, I have tried all recoveries and kernel. but still has the same problem.
:crying:
Hello everyone,
I am using Elephone p7000 Android 5.0 Lollipop
I want to set my default application installation location to external sd card instead of the phone's internal memory.
For this i landed on an internet page which says as follows :
Beginning with API Level 8, you can allow your application to be installed on the external storage (for example, the device's SD card). This is an optional feature you can declare for your application with the "android:installLocation" manifest attribute. If you do not declare this attribute, your application will be installed on the internal storage only and it cannot be moved to the external storage.
To allow the system to install your application on the external storage, modify your manifest file to include the android:installLocation attribute in the <manifest> element, with a value of either "preferExternal" or "auto". For example:
<manifest xmlns:android="http : // schemas . android . com/ apk / res/android"
android:installLocation="preferExternal"
... >
Therefore,
I wanted to know which program should i use to execute the above commands or if it is possible to do the above operation in the Virtuous Ten Studio and how to do it.
I would really appreciate your help in this regards as i very badly need to install applications on my Micro SD card instead of the internal memory.
Thanking you,
Regards,
Muhammed Irfan Khan
muhammedirfankhan said:
Hello everyone,
I am using Elephone p7000 Android 5.0 Lollipop
I want to set my default application installation location to external sd card instead of the phone's internal memory.
For this i landed on an internet page which says as follows :
Beginning with API Level 8, you can allow your application to be installed on the external storage (for example, the device's SD card). This is an optional feature you can declare for your application with the "android:installLocation" manifest attribute. If you do not declare this attribute, your application will be installed on the internal storage only and it cannot be moved to the external storage.
To allow the system to install your application on the external storage, modify your manifest file to include the android:installLocation attribute in the <manifest> element, with a value of either "preferExternal" or "auto". For example:
<manifest xmlns:android="http : // schemas . android . com/ apk / res/android"
android:installLocation="preferExternal"
... >
Therefore,
I wanted to know which program should i use to execute the above commands or if it is possible to do the above operation in the Virtuous Ten Studio and how to do it.
I would really appreciate your help in this regards as i very badly need to install applications on my Micro SD card instead of the internal memory.
Thanking you,
Regards,
Muhammed Irfan Khan
Click to expand...
Click to collapse
I suggest you use xinternalSD but you must have exposed to make it work for you. after installing open storage path and write /storage/sdcard1 after that reboot your phone...come back to open the app and select enable all apps. or better still you can just click on the enable apps and tick the apps you want to be written to sd card. thanks
Emmago said:
I suggest you use xinternalSD but you must have exposed to make it work for you. after installing open storage path and write /storage/sdcard1 after that reboot your phone...come back to open the app and select enable all apps. or better still you can just click on the enable apps and tick the apps you want to be written to sd card. thanks
Click to expand...
Click to collapse
I tried xinternalSD but the Xposed Modules App says is not compatible
muhammedirfankhan said:
Hello everyone,
I am using Elephone p7000 Android 5.0 Lollipop
I want to set my default application installation location to external sd card instead of the phone's internal memory.
For this i landed on an internet page which says as follows :
Beginning with API Level 8, you can allow your application to be installed on the external storage (for example, the device's SD card). This is an optional feature you can declare for your application with the "android:installLocation" manifest attribute. If you do not declare this attribute, your application will be installed on the internal storage only and it cannot be moved to the external storage.
To allow the system to install your application on the external storage, modify your manifest file to include the android:installLocation attribute in the <manifest> element, with a value of either "preferExternal" or "auto". For example:
<manifest xmlns:android="http : // schemas . android . com/ apk / res/android"
android:installLocation="preferExternal"
... >
Therefore,
I wanted to know which program should i use to execute the above commands or if it is possible to do the above operation in the Virtuous Ten Studio and how to do it.
I would really appreciate your help in this regards as i very badly need to install applications on my Micro SD card instead of the internal memory.
Thanking you,
Regards,
Muhammed Irfan Khan
Click to expand...
Click to collapse
I'll advice u use either deepflex DCU ROM to b able to achieve that