How to access system folder in android without rooted? - android

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.

Related

How to permanently delete file from the Android shell without root

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.

Removing an sqlite db in Android

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 .

Android Cannot see anything inside data folder

i am trying to see SQLite database in anyway possible (I have a rooted device). I tried File explorer in eclipse but i cannot see anything under data folder. Can anybody please help me with this
I tried to search everywhere but couldnt find a clear solution.
I also tried adb shell but i cannot see list of things inside data folder using "ls" command.
error
Opendir failed. Permission denied
I am guessing this has something to do with rights but how can i fix it
Please help
You need root premission to explore DATA directory...
From phone
I use terminal emulator to do the job..... Simply open terminal then type in su after that it will ask for premision. then you need to type cd data/data/WhereEverYouNeedToGo/databases and "WhereEverYouNeedToGo" should be package name. After that you could do whatever you want with your database.
from PC
open terminal or cmd goto your adb directory then run adb shell then su and then
cd data/data/WhereEverYouNeedToGo/databases
Hope it helped.
Run adb in root mode using "adb root"
adb shell
su
ls /data/
Try this
You have been given a number of answers for how to leverage the root capability, however as android is designed without the assumption of root there are other methods as well which you can use while developing apps.
1) Include functionality on an expert menu to copy the database to the sdcard; there is no file copy method in android java (and in most stock cases no 'cp' shell command), but you can find numerous answers here with a copy routine.
2) Make your apk debuggable and use the run-as command to obtain a shell running as the application userid and starting in the app's data directory. You can then copy the database to the sdcard if the app has that permission.
3) Have your app set the permissions on the database file during development to world readable. Although you cannot browse the directory tree to down to it, you can then adb pull the database file by giving it's full path name.
You need to have either routed device or your device should be a "Android Dev Phone" to explore that directory. Trying checking the same using emulator, you will be able to see the data folder contents.

Delete files from DDMS using command prompt?

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.

Why can't 'data' folder be displayed just like in DDMS file explorer?

I list out files in '/' by:
File directory = new File("/");
fill_listview(directory.listFiles());
And I get those in list:
sqlite_stmt_journals
config
cache
sdcard
d
etc
system
sys
sbin
proc
init.rc
init.goldfish.rc
init
default.prop
data
root
dev
I have two questions:
1.Why cann't I access '/data' folder just like Eclipse DDMS file explorer?
2.Why it is different from the DDMS which show only:
data
sdcard
system
Thanks!
On rooted device you can do this to access the /data folder:
Open cmd
Type 'adb shell'
su
Press 'Allow' on device
chmod 777 /data /data/data /data/data/com.application.pacakage
Go to the DDMS view in Eclipse
After this you should be able to browse the files on the device.
It is mostly because of security issues. If /data folder is visible to everyone, then some malicious app can read/temper/delete the data of some other app which can get really worse if some app is storing some sensitive data like password/credit card number etc. So the whole filesystem is only visible via debug console (or ddms).You can not access data of any app on the device unless it is rooted because by doing so, integrity of system might be compromised and it may lead of weird behavior. Which means you can not access cached data/databases of app.
I did this on a non-rooted device and it worked
run-as com.your.package ls -l /data/data/com.your.package
run-as com.your.package rm /data/data/com.your.package/databases/mydatabase.db
Reference: http://denniskubes.com/2012/09/25/read-android-data-folder-without-rooting/

Categories

Resources