So I'm making an app that requests a file from the phone's storage (external storage - not external SD Card, the internal one). But the path is awkward when I select the file from Downloads: /document/[number here, for example, 4].
Does anyone know how to get the real path of that file? Because it exists on the Download folder, but I wanted it to when it's selected, I get the real path of it and not that weird path which actually doesn't even exist. This happens at least on Nougat (Android Studio emulator) and on KitKat (both the emulator and my phone). Any help is appreciated.
As pointed by Abhay Koradiya and Nandan Desai, the path was an Uri path, so I used this code to solve the problem and convert to normal path, given by Abhay Koradiya: http://technophilegeek.blogspot.com/2018/11/android-get-file-path-from-uri-real.html. Again, thank you both for the help!
Related
After updating to Android 6.0.1 i can't find the files on my sdcard programmatically.
The SD Card directory shows now "storage/9C33-6BBD/"
After this path I has my data.
How i can get them ?
System.getenv("SECONDARY_STORAGE");System.getenv("EXTERNAL_STORAGE")Environment.getExternalStorageDirectory()
Doesn't work
Before updating Androiud it works well.
Have a look at getExternalFilesDirs(). It will give two paths. The second one in on the sd card.
I want to get the emulated storage path. System.getenv("EMULATED_STORAGE_TARGET") works on previous versions i.e Android 5 and below but returns null on Android 6. I searched on google but couldn't find anything. How can I get the emulated storage path on Android 6. Any help will be appreciated. Thanks in advance!!
You appear to be referring to external storage, which on some versions of Android will be located at /storage/emulated/0/. The proper way to obtain the root of external storage, on all versions of Android, is by means of Environment.getExternalStorageDirectory().
If you find yourself using environment variables in an Android app, you are doing it wrong.
Our game is bigger than 50Mb so we will be using an expansion file. This supposedly goes in the /Android/obb/package-name/ folder. To test it, we copy the file to that location using Windows file explorer.
To find the location, we call
String dir1 = Environment.getExternalStorageDirectory().getAbsolutePath();
However, on some device, it cant find the file
e.g. the GalaxyTab2.7.0 - the above call returns the location /storage/sdcard0, but it cant open the file /storage/sdcard0/Android/obb/package-name/base.tcf, even though we have copied it there, using Windows file explorer, to the Android/obb/package-name/ folder.
Now, maybe this "Android" folder is not the same one as the storage/sdcard one - maybe I CAN only put it on an sdcard ? But this same thing works on Nexus 10 and Sony Experia device, with the same paths, which don't have sd cards in them.
To get this working on other devices we had to put READ_EXTERNAL_STORAGE permissions in the manifest file. Maybe there is another permission ? Maybe once we actually download the expansion file, it will just work, but we can't test it otherwise.
Any ideas?
Thanks
Shaun Southern
How do we get a current wallpaper absolute path
On Android 4.2 the wallpaper is located at:
/data/system/users/0/wallpaper
Replace the 0 with your user id (take a look in /data/system/users).
Make sure you are looking in the phone's root directory to start, NOT on the SDcard. Once you get to the right subdirectory the wallpaper file will just be called "wallpaper" and until you copy it to the SDcard and rename it to "YourName.jpg" the picture viewers may not recognize it as an image file.
I tried both ES File Explorer and Root Explorer (download from Marketplace) to copy the file from the phone root area., i.e. phone ROOT/data/data/com.android.settings/files/wallpaper...it's the lowest level of the phone storage itself, similar to "computer" in windows.
Probably the File Explorer on your phone won't let you access the root (your phone shouldn't need ROOT privileges just to copy the file)
use wallpaperManager and call getWallpaperInfo. This will return you a wallpaperinfo object which contains all the info about the wallpaper. Read more about the wallpapernfo here.
I would imagine that the current wallpaper will be stored in a private system folder.
On Android Oreo and using one of the provided wallpapers from the system, the wallpaper I wanted wasn't on the path mentioned by the accepted answer but I found the apk that had it on a system folder.
I got it from the path: system/framework/framework-res.apk
I had to open the apk and extract: /res/drawable-nodpi-v4/default_wallpaper.png.
Android Oreo is not in the place from other comments
Internal Storage/Android/data/com.android.systemui/files/backupwallpapers
I just had to find a wallpaper that I deleted from my downloads folder.
Download the apk file ...
go to this path...you can find it here
Download\com.amber.launcher.skin.samsung.galaxy_2018-08-24\res\drawable-nodpi-v4\bg_wallpaper.jpg
I just want to view the files(especially the .png files) associated with one of the application in my mobile. The application is actually installed(moved) in the SD card.
The issue is ..I could not find the application in the SD card. I am using a file browser called 'File Manager' to browse through the SD card. Can someone help me on this.
It should be here:
/mnt/sdcard/Android/data/your_package_name/
Some hardware implements the path to the external storage different.
/mnt/sdcard/Android/data/your_package_name/
/mnt/sdcard-ext/Android/data/your_package_name/
You may be able to get a better view of what is on the device by using the ADB Shell. If you still have trouble at this point trying running grep or find from the shell.
UPDATE
Most of the time the files associates with your application are in the directory with your application. The application is installed in /data/data/your.package.name/. However you will need root access to get here if you are on a phone, I think the emulator lets you get here. As far as external storage... yea its a pain, to much fragmentation in the market. You have to programmatically check the location of the external storage.
On my device with Android 2.3.6 apps moved on the SD card are located into a directory named .android_secure as .asec files (see http://www.fileinfo.com/extension/asec).
They are not visible from the standard "Archive" browser which shows the hidden directory as empty.
The files are also encrypted so I guess no access to the images within is possible.