Android : how to check if a file exist using adb shell

on Friday, September 12, 2014


I have a bash script which goes as follows



if [ -f "/sdcard/testfile"]
then
echo "exists" > /sdcard/outfile
else
echo "does not exist" > /sdcard/outfile
fi


I have sufficient permission to run this with /system/bin/sh I am calling this script from my application and running this with /system/bin/sh But after running I am getting false, even if the file '/sdcard/testfile' is there. When I am explicitly running in adb shell, I am getting this error


**[: not found**


Is there any other way to accomplish this task? I cannot just use java.io.File because of permission issue of application, therefore I am adhering to shell script (command).


0 comments:

Post a Comment