I am practicing to create a system app and testing using a rooted device. The application copies files(images,music and video) from a zip file to a the directory /data/media/0/SampleFolder. But after the files are copied, they are not recognized or can not be opened when viewed using ES File Explorer File Manager.
When I view via adb shell and enter the command ls -l /sdcard/SampleFolder/, the files are then recognized and they can be opened after entering said command. If not mistaken, the paths data/media and sdcard have symbolic links.
Does this mean that there is a sync problem between /data/media and /sdcard/ and if yes, is there a way to refresh it programmatically?
Note: The following have been tried but have not been successful:
Rebooting the device
entering ls -l command programmatically
called MediaScannerConnection.scanfile for each file in the /sdcard/SampleFolder directory
broadcasting Intent.ACTION_MEDIA_MOUNTED in Environment.getExternalStorageDirectory
broadcast Intent.ACTION_MEDIA_SCANNER_SCAN_FILE for each file in the /sdcard/SampleFolder directory
Related
I can use the file explorer fine with the emulator, but when I try to open directories with an actual device, it is unable to open the directory.
I have selected my device under the Devices tab, and I can see the directories under the file explorer tab.
If I try to used adb shell on the cmd line, I can see the directories but when I try to open them I get: "opendir failed, Permission denied"
the permissions on the directory are drwxrwx--x
I feel like there might be some permission setting on the device that I am overlooking, any ideas?
You cannot access most of the filesystem on production devices, except perhaps on rooted ones, by any means, let alone DDMS' file manager.
For your own app, you can use adb shell run-as to copy a file to external storage, then copy it off from there using DDMS' file manager, or adb pull, or just using your normal desktop OS to copy from the mounted storage.
I was attempting to access the data data folder of an application without rooting . I followed How to access data/data folder in Android device? and was able to access the folder.
Now I was trying to copy the required file from data/data to a folder in my SD Card , however I get a permission denied on it. In the thread I have referenced above , no body complained of this behaviour so I suppose it shouldn't happen at my end too .
This is exactly what I am doing
C:\AndroidSdk\platform-tools>adb shell
shell#D6503:/ $ run-as com.xxx.xxx
run-as com.xxx.xxx
shell#D6503:/data/data/com.xxx.xxx $ cp databases/xxx.db /storage/sdcard1/Pictures/
cp: /storage/sdcard1/Pictures/xxx.db: Permission denied
I have verified that the folder /storage/sdcard1/Pictures is accessible through shell.
Happened to me as well. This is what I did to access the contents of the data folder of my app in my Nexus 5 (Android 5.0), without having root access or chmoding any file:
Open a console where your ADB is located and execute:
adb backup -noapk com.your.packagename
You will be asked to accept the backup on your device. Accept it and don't use any password. Once the backup process is completed, you will have a file with .ab extension on your ADB folder.
The backup will be compressed in a special way, you can decompress it with this tool: Android Backup Extractor
To use it, unzip it and put the backup file (*.ab) on the same folder where the extractor (abe.jar) is. Then open a console there and execute the following command:
java -jar abe.jar unpack NAME_OF_BACKUP.ab NAME_OF_BACKUP.tar
Notice that the result of this operation will be a *.tar file, which can be opened or decompressed with WinRAR or many other compression tools.
OPTIONAL for SQLite Databases: If you want to see the contents of the database, you can use this Firefox plug-in: Firefox SQLite Manager
I am using android studio and 'samsung tab 2' as my testing device. I want to see the files of my application. So i clicked the 'Monitor' button. Then i selected my device from device list and selected my application package.There is a Data folder in file explorer. But when i clicked on the data folder it shows nothing.When i run this application using emulator the file explorer shows the data folder and i can see every files in my application. how can i see my files inside the data folder when using device ?
I found a solution based on the answer in stack overflow .
How to access data/data folder in Android device?
First i rooted the device .Then i modify the access permission of data folder using adb shell.
the code is
$ adb shell
$ su
# mount -o rw
1|root#android:/ # chmod -R 777 data/
Now i can access the files.Thank you #param for your valuable comment.
I am trying to develop a simple pygame with Ubuntu Linux 11.10 for my Motorola android phone. I am having trouble getting the "adb push" command to work. I get an failed to copy 'foo.txt' to '/media/MOT': No such file or directory error message. What am I doing wrong?
Here is what I tried so far:
The phone's SD card is mounted at /media/MOT/ and I am able to ls, create a folder and delete a folder in it.
user#linuxlappy:~$
user#linuxlappy:~$ cd /media/MOT/
user#linuxlappy:/media/MOT$ ls
Android burstlyImageCache burstlyVideoCache data DCIM download gstomperdemo LOST.DIR slacker temp.apk
user#linuxlappy:/media/MOT$ mkdir writetest
user#linuxlappy:/media/MOT$ rmdir writetest/
The file that I am trying to copy is foo.txt in my /home/user/ directory
user#linuxlappy:/media/MOT$ cd /home/user/
user#linuxlappy:~$ ls foo.*
foo.txt foo.txt~
I enabled USB debugging on the phone with:
Settings > Applications > Development > USB debugging.
I believe I have adb installed correctly, I am able to list the phone with adb devices.
user#linuxlappy:~$ adb devices
List of devices attached
0910E8201700B017 device
When I try to push a simple text file to the SD card I get this error message.
user#linuxlappy:~$ adb push foo.txt /media/MOT
failed to copy 'foo.txt' to '/media/MOT': No such file or directory
user#linuxlappy:~$
The phone's SD card is mounted at /media/MOT/
Based on your terminal output, it is mounted on your desktop Linux environment as /media/MOT. In which case, to copy files to it, you use cp.
Using adb push, you need to use the path where the external storage resides on the phone. A common spot is /mnt/sdcard/, though it may vary. Also, bear in mind that, depending on your phone, external storage may not be available while you have it mounted as a volume on your desktop Linux environment.
For debugging purposes, I wanted to have a couple of mp3 files located somewhere "in" my android emulator. Is there anyway to directly push files from my OS file system to the storage system of android?
If so, which directory does android keep audio files?
if not, how can I access an SD card via emulator?
[update2]: The problem in update1 solved. Should use adb push.
[update1]: I followed kgiannakakis's advice to create an sdcard for my avd. However, I got Permission denied error when I try to create new directory inside it.
$ cd sdcard
$ ls
LOST.DIR
$mkdir musics
mkdir failed for musics, Permission denied
$ su mkdir musics
su: uid 10016 not allowed to su
You can find directions for emulating an SD card here.
I believe that the easiest way to copy files to the SD card is to use the adb utility.
See here for a more advanced solution.
Regarding instructions at http://android-er.blogspot.com/2009/10/create-sd-card-in-android-emulator-and.html on creating the 'pictures' folder, you can run the same commands from the adb shell, instead of running them from inside the emulator.
So get a command line at e.g. C:\Program Files (x86)\Android\android-sdk-windows\platform-tools (on 64bit windows), and run adb shell.
Then you can run the same commands:
#cd sdcard
#mkdir pictures
and create the directory successfully with no permission denied error.
Following same instructions, in DDMS I had to browse to \mnt\sdcard to find the SD card volume.