I'm creating an Android application for which I need to delete a confidential image of such a kind that it won't be possible to restore it, at least not easily.
The solution I'm exploring is to use the my shell access without root.
With Android shell I can delete the file with the linux command 'rm'.
I was wondering how to use commands like linux shred or srm without having to install it because I don't have root access. Can i run a linux package as portable version?
The file can be in the application directory /storage/emulated/0/Android/data/com.myapp.
No ADB, No Java.
Related
I am developing an application using ionic framework.
The app creates files (*.json) and stores them in /data/user/0/ when i verify whether they exist or not, the result was true which means the files exist in the mentioned directory and I can access and modify their content without problem, but when I check the directory with a file manager or from the computer, no result, the directory is empty.
Could someone tell me what should I do?
use adb to copy the file. Even if it's in root dir, u should have access to it via adb.
Do adb pull data/user/0/filename.json path_on_ur_comp.json.
this will copy the file to the directory you define in the 2nd parameter.
// EDIT:
adb is part of the Android SDK, stands for Android Debug Bridge.
You can use this for MANY MANY different reason but of course, the "main" reason is to debug Android devices. You can use it to transfer files in your case.
In Windows, it's located here:
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools\adb
In Mac, it's lcoated here:
/Users/USERNAME/Library/Android/sdk/platform-tools/adb
Depending on which OS you use, open that either with Terminal (Mac) or Command Prompt (Windows).
Once you do that, run the following command:
For Mac:
adb pull data/user/0/filename.json /Users/USERNAME/Desktop/somefile.json
For Windows:
adb pull data/user/0/filename.json c:\Users\USERNAME\Desktop\somefile.json
This will copy the file and put it on your desktop
I'm debugging my android app in Android Studio using a real android device and. I see that the Sqlite db path is
/data/data/com.my_app/databases/data1.db
I want to remove it. By that path doesn't exist when try to find it by a file manager. And, of course, this isn't working:
adb -e shell rm /data/data/com.my_app/databases/data1.db
adb server is out of date. killing...
* daemon started successfully *
error: device not found
So how can I remove it and why isn't it visible in my smartphone?
why isn't it visible in my smartphone?
Because it is on internal storage, which you do not have access to, except on emulators and rooted devices.
And, of course, this isn't working:
That is some separate problem with adb running on your machine.
So how can I remove it
If you want to completely clear your app's data (databases, SharedPreferences, and other files) on internal storage, use the Settings (e.g., Settings > Apps > (your app) > Clear Data on Android 4.x/5.x).
If you specifically want to get rid of this file on an emulator, the command you tried should be fine. I suggest restarting the emulator.
If you specifically want to get rid of this file on production hardware, you will need to use run-as:
adb shell run-as com.my_app rm /data/data/com.my_app/databases/data1.db
You can't reach that directory if your device isn't root . For change or modify system files you must have root access .
I'm unable to access system folder in android without rooted the device. Also wanted to know is it possible to access while booting the android phone?
I think ur asking without doing rooting
so Without rooting you have 2 options:
If the application is debuggable you can use the run-as command in adb shell
adb shell
run-as com.your.packagename
cp /data/data/com.your.pacakagename/
You can use Android's backup function.
adb backup -noapk com.your.packagename
You will now be prompted to 'unlock your device and confirm the backup operation'. It's best NOT to provide a password, otherwise it becomes more difficult to read the data. Just click on 'backup my data'. The resulting 'backup.ab' file on your computer contains all application data in android backup format. Basically it's a compressed tar file. This page explains how you can use OpenSSL's zlib command to uncompress it.
You can use the adb restore backup.db command to restore the backup.
regards maven
Every app can access and read the /system folder on an Android device. It does not have to be rooted for that.
No, you can't.
The user that launchs the application must be root in order to access some folders. If doesn't have permissions to access a directory you cannot access to it. It's a UNIX security measurement, you can't bypass it.
I have compiled a native application, a terminal only application basically, with the android NDK, my main problem right is that I can't change the permissions on my executable ( a dynamically linked one ) like so chmod +x executable to test and use the application.
I need to root my device just to do that ?
I tried with both adb shell and a random terminal application directly from my phone.
No, you don't need to root a device to use executable binaries. You cannot put it on /sdcard but on most devices there is a directory /data/tmp or /data/local/tmp where you can push files with adb and execute with adb shell.
The robust option is to package an executable in an APK and get it on device by installing the APK, see Is it possible to run a native arm binary on a non-rooted android phone? or How to package native commandline application in apk?.
Note that you cannot change the LD_LIBRARY_PATH, so be careful if your executable depends on some shared libs that are not part of /system/lib.
These guys say root is needed:
How to compile C into an executable binary file and run it in Android from Android Shell?
From my understanding, the regular sdcard is mounted with no execution permission, so you need to write to something like /data/local/, which indeed requires root access.
If you don't package your native code as an Android app, you'll need to run it from shell.
Starting with Android KitKat/Lollipop, executables can only be run from restricted locations. eg an executable installed in /data/data//... will not be allowed to run in any ways, be it with or without root.
Before KitKat, one can copy the executable to its own data directory, make it executable and run it. Not anymore in more recent version of KitKat.
So you will definitively need root to run linux exe on recent versions of Android.
I'm trying to delete some files from DDMS data/data/package_name/files/filename How can i done this?
adb shell rm /yourpath/to/yourfilename
Use the File Explorer of the Eclipse DDMS plugin or the adb shell command from your android platform tools to browse and delete the file system on your device.
You can use ADB to get into the device/emulator shell and then execute normal linux-commands.
In your case, you would use rm to remove something (if you want to remove a folder use the -r parameter).
From the Android Docs:
Internal Storage
You can save files directly on the device's internal storage. By
default, files saved to the internal storage are private to your
application and other applications cannot access them (nor can the
user). When the user uninstalls your application, these files are
removed.
This might help you. You can also check if you can "delete application data" in Androids Application Manager.