Hi all, I am aware how to use sqlite3 on emulator to monitor data of app. Is it possible to use on a real device?
My device is Nexus S when I try on my device it says sqlite3 is not found. Is it compulsory to sqlite 3 device must be a rooted one? My device is not a rooted device.
I am aware of other mechanism of looking data for example dump db file in SD card then use third party SQL browser to look into the data.
U cant use Sqlite3 instead u can do this.
The following solution works only for apps that are debuggable. It may not work well on all devices, since run-as command doesn't work on some devices, especially with Jelly Bean.
Create a *.bat or a *.sh file and copy the following scripts
adb shell run-as [package] chmod 777 /data/data/[package]/databases/
adb shell run-as [package] chmod 777 data/data/[package]/databases/[db_file_name]
adb shell cp /data/data/[package]/databases/[db_file_name] /sdcard/
adb pull /sdcard/[db_file_name]
Change [package] to the desired application package
Change [db_file_name] to the desired db name Run the bat file and
you should see the copied database in the same folder as the bat
file
If you're asking about using sqlite3 on shell (terminal), then no -- first you can't access the databases folder in your app because of permissions. second there's probably no sqlite3 installed in your non-rooted phone.
lucky enough, your nexus s, being a nexus device, is one of the easiest devices to root. there's even a tool created to root any nexus device - get it here.
After rooting, follow instructions on the third post here to install sqlite.
Related
If you attach android device to PC you can browse files and dirs. It is possible to get this directory using Environment.getExternalStorage(). You can use it from your application and create accessible files and dirs. It works fine.
On my devices this path looks like /storage/emulated/0 and if i try adb push to this directory i will get access denied error. Is it possible to copy files using adb to the same folder as Windows Explorer does?
D:\...\tools>adb push ACCOUNTS.DB /storage/emulated/0
failed to copy 'ACCOUNTS.DB' to '/storage/emulated/0': Permission denied
58969 KB/s (606505 bytes in 0.010s)
I'm implementing automated import/export and i want files to be accessible without adb shell in case anything will go wrong.
Currently using variable$EXTERNAL_STORAGE as workaround, it works for both adb and application.
Device: Asus Fonepad 7, Android 5.0, tried Genymotion Custom Tablet 6.0 - works.
Try to use /sdcard/. Although it is strongly discouraged to do this in code. It seems to be the only way with adb :
$ adb push somefile /storage/emulated/0/somefile
[100%] /storage/emulated/0/somefile
adb: error: failed to copy 'somefile' to '/storage/emulated/0/somefile': Read-only file system
$ adb push somefile /sdcard/somefile
[100%] /sdcard/somefile
By the way, on my device they don't have the same value : Environment.getExternalStorage() points to /storage/emulated/0/ while /sdcard points to /storage/emulated/legacy.
It's pretty easy, internal storage is unavailable on non-rooted devices. So as was mentioned in bwt answer you just need to push your data to sdcard :
adb push somefile /sdcard/somefile
With retrieving files from your filesystem you'll also have few problems. But with the case of pulling a database from a debug application - you'll just need to change file permission via chmod.
Here you have a useful link - XDA guys about adb
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.
Hi so my application runs some commands using the su in android root.
It works fine in JellyBean on the Galaxy Nexus but when I try to run it on the LG Nexus 5 (kitkat), I get an error saying:
su: uid 10069 not allowed to su
I'm not really sure what I'm missing here. I have root access (it runs su fine on the Galaxy Nexus).
Basically the application reads in a command from a TextEdit, strips it, appends the necessary parameters etc. and then calls the script which is put on the phone. I use the ProcessBuilder to build the call for the script.
Any fixes or ideas as to where I should look would be appreciated. Thank you
The issue was SuperSu not being properly installed and granting permission to the application. Once I changed that there were no permissions issues.
If you have problem with rooting to super user.
You can use "run-as" command to access files of your application.
ex: run-as com.your.package
It will drop you to the shell#android:/data/data/com.your.package $
now you can use commands ls
Then it will display the list of file folders
cache
databases
lib
shared_prefs
I try to work with SQLite but I don't know what I'm doing wrong.
I've made an example to insert a records and it works but I can't see the database. I'm working with a real device.
I've found (in Internet) that the database should be in:
/data/data/paquete.java.de.la.aplicacion/databases/database
But this folder seems empty. I've tried with oi File Manager application and File Explorer of Eclipse.
On the other hand, I'm sure that the records have been inserted because if I debug, I can see the them in Log Cat.
Any ideas?
Thanks in advance.
As long as the application is built in debug mode there is no need to have the device rooted. Try
adb shell
run-as your.package.name
ls databases
In order to see the database files on a phone or through eclipse, your device needs to be rooted. If you want to test your database to see what it looks like and if it's working otherwise, you can run your app on the emulator and see it just fine.
What is rooting..?!
You need to be rooted to be able to see the database.
With the emulator you have root access and you can use sqlite3 to open the database from within an emulator shell. Use .dump to dump all contents of the database.
So the commands you would have to do:
Open shell on emulator:
adb shell
Within shell:
cd /data/data/paquete.java.de.la.aplicacion/databases/databases
sqlite3 *yourdatabase.db*
Within sqlite3
.dump
Mit .exit geht's wieder raus aus sqlite3.
I have my Nexus One connected with the USB.
When I visit the File Explorer of the DDMS, if I click on the "data" folder the little plus near the name "data" disappear for 2-6 seconds and then reappear but the contenct of the folder "data" is not showed!
Here some other information:
the folder data has permissions drwxrwx--x
the OS of my PC is Windows XP
Eclipse v. 3.5.2
Android SDK 1.6
If the adbd daemon is running as root, you can browse /data using adb-based tools such as the DDMS file explorer or the adb shell.
If it's not, you can access a few files under /data and its children directly by their full path names, but you cannot browse (or 'cd' to) most of the folders, including /data itself.
"rooting" as an unofficial process means varying things and produces varying results - ie, adbd may or may not run as root.
If ro.secure is set to 0 in the startup scripts such as /init.rc, adbd will run as root, but that may not be a good idea on a user device. It is set to 0 on the emulator, and that's why you can browse /data there.
Finally, note that /init.rc is usually contained in a ramdisk image packed onto the kernel - you can't really edit it on the phone but would have to modify the image offline, re-attach it to the kernel, and re-flash them. Though if you have some sort of working 'su' hack you may be able to change the property temporarily and restart adbd.
In this link (http://denniskubes.com/2012/09/25/read-android-data-folder-without-rooting/) Dennis Kubes shows a method for accessing your application's data folder without root access.
Turns out there is a simple solution, the run-as command.
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
That will allow you to run commands as your app. You can also use run-as in interactive mode.
run-as com.your.package
shell#android:/data/data/com.your.package $ ls
cache
databases
lib
shared_prefs
rm databases/mydatabase.db
Interactive mode will drop you into the data folder for your app. You can navigate from there.
I don't think anyone really understands this question. Giorgio can use the DDMS File Explorer to browse the ./data folder on his phone. Pentium10 talks about needing root access on the phone.
Well I a retail Nexus One and a developer Nexus. I have always been able to use DDMS File Explorer to browse the ./data folder on my developer phone but not my retail phone. So I rooting my retail phone would help. I didn't.
So the bottom line is there is something different about the retail and developer phones. Until more research is done you won't be able to browse the data folder on your phone.
Hope this helps.