Root Android phone - android

I have created a database for my app and I want to check .db folders to check the data inserted while developing. But my Android mobile will not allow to access data folder. To achieve this I have rooted my mobile with GingerBreak.apk. Device rebooted but nothing happened. How can I check my data base from my phone.
Note: I can't check the data using emulator, because app cant run on emulator, it uses, Bluetooth, WiFi,etc.
Regards,
Krishna

You need to install some file broswer(such as R.E file manager) to access to these .db files. They are located in /data/data/{package name} dir.
Meanwhile, you can access these file via command line.
For emulator:
Type adb shell in the command line, and you can see a "#" prompt.
Type 'cd /data/data/{package name}` to go to the very dir where the
.db file is located.
Now type sqlite3 <db file name, no extension> so that you can execute SQL command to read and control the .db file. Now you can see a "sqlite>" prompt.
For real device(phone must be rooted):
Step 2 and 3 are the same. In Step 1, you have to type "adb shell", and then "su" to see the "#" prompt.
Hope it helps.

To root your phone. You can use lucky patcher app.Although there are plenty of apps available around internet but i found it worth using
By using this app you can not only root your device as well as remove annoying ads and much more.

Related

How can I find my app and the SQLite .db file in Android

I created my first Android App with SQLite and tested it on my phone.
Now I installed an SQLiteManager on the phone and I would like to open the SQLitedatabse file.
The location is /data/user/0/com.<appname>/database/database.db
But this folder does not exist. How can I find and access the database file?
And I am also not able to find the apk of my App. In Android/data/ I can see all other installed apps, but not my own app.
How can I find yout where it is located?
The acutal path is /data/data/package.name/database.
If your app is in debug mode, most newer devices allow accessing this folder via Android Studio (or adb run-as). On the emulator this folder is public.
Just run the command in terminal
adb pull /data/data/com.example.myapplication/databases/your_db.db
No need to root your device.
I used this way on Mac with Terminal:
sudo adb -d shell "run-as com.YOUR_COMPANY.YOUR_APP_NAME cat databases/YOUR_DATABASE_NAME.db" > NEW_NAME_FOR_DATABASE.sqlite
Sometimes you need first to give that file a permission 666, so you can copy it to your computer.
chmod 666 YOUR_DATABASE_NAME.db
Your device must be Rootable for you to be able to see the .DB file
for the second question, try to search for your package name first. Maybe it's like xxx.xxx.Christina.xxx.AppName ?

How to access android root directory

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

How to retrieve files created by an android app?

My android app creates an sqlite database and I need to get it off the device so I can look at the data with a database viewer.
Was hoping I could just issue >adb shell and then go find it somewhere on the file system. Looks like there are permission issues with lots of commands. Even just running >find . -name *.sqlite gives permission denied.
Can anyone advise on how to do this?
It seems your device is not rooted, anyway..
Copy your .db file form /data/data/<package_name>/databases/ to ExternalStorage using code.. Then you can get it via adb pull command or DDMS -> FIle Explorer.
Currently there is no way to browse database on the device (without getting the root permission as you want) .
You can browse your database from emulator using adb shell.

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.

Viewing private files created by an android app

I have an xml file being written by an app that is set to MODE_PRIVATE, but I now want to read that file outside of the phone, for debugging purposes. In Eclipse, I can access other files made by the app and copy them to my computer, but I can't even see this private file. Merely changing the file to MODE_WORLD_READABLE file doesn't seem to help. I think the file is being stored on an internal "SD card" that can not be removed from the phone, but there are also two other folders in the File Explorer that are either empty or inaccessible: asec and secure.
Does anyone know how the file can be accessed?
If your app is installed in debug mode, you can get your private files on a device without rooting.
Go to [android-sdk]/platform-tools folder and run adb shell.
run-as com.example.yourapp
cp -r /data/data/com.example.yourapp /sdcard/
(Where com.example.yourapp is the package name of your application.)
After executing the steps above, the private folder of your application is copied into the root of your sdcard storage, under your package name, where you have permission to download and view them.
Note 1: If you don't need to download them, then instead of step 3, you can use unix commands to navigate around and list files and folders.
Note 2: Starting from Android Studio 2.0, you'll find more files in the cache and files/instant-run folder, related to the Instant Run and the GPU Debugger features, placed there by the IDE.
You will need to connect the phone and do some magic to let your sdk work with it (I think put it in debugging mode?). Go to where you unzipped the android sdk:
C:\android-sdk_r10-windows\android-sdk-windows\platform-tools>adb shell
#cd data/data/com.yourpackage.yourapp/files
#ls
You should see your file listed. You may need to run "ls data/data" if you're not sure what the fully-qualified name of your app is. From here if the file is small and you just want to see what's inside it you can run:
#cat yourfilename.xml
Alternatively:
#exit
C:\android-sdk_r10-windows\android-sdk-windows\platform-tools>adb pull /data/data/com.yourpackage.yourapp/files/yourfile.xml
Note: I have only tried this on the emulator, I don't know how to use adb with a physical phone.
You need to root your phone to see Context.MODE_PRIVATE files
It ends up being stored in data//files I believe but you need root permission to see them
So either root your phone or wait until you finished debugging and then add Context.MODE_PRIVATE
If Eclipse is used, there is one more option:
DDMS Perspective > File Explorer tab > data/data/com.yourpackage.yourapp/files
where you can pull/push/delete files.
Another option is to have a command in the app that dumps the private files. This only works if you don't want to edit the files, but has the added bonus that you don't have to strip it out before it goes to production, because the user can't break anything with it. Well, as long as the files don't contain sensitive information. But, really, if they do, you're doing something wrong. As #user1778055 said, a user can root their phone to access it.

Categories

Resources