inspecting android sqlite and IntelliJ - android

I'm starting out with a small app using programmatically created sqlite db.
Is there a way to inspect that db when the app is running on emulator?

You can download the database file from the device to your PC and then use any SQLite browser / tool to inspect the database.
Either via the adb commandline tool from the Android SDK tools
adb pull /data/data/your.app.package.here/databases/yourdatabasefile.db
or via the device browser (File Explorer) in Eclipse in the DDMS perpective (maybe that exists in IntelliJ too, Idk)
or the new Android SDK tools provide a neat standalone version of that DDMS perspective & the file explorer via the new Device Monitor tool (android-sdk/tools/monitor.bat)

This is now possible with IntelliJ IDEA 14:
https://www.jetbrains.com/idea/help/accessing-android-sqlite-databases-from-intellij-idea.html

A partner found a more dynamic solution, using an ADB plug-in you can simply choose the database and refresh the inspector any time you want
first, you need to download the plug in jar
https://github.com/tklerx/android-sqlite-browser-for-eclipse
(go to releases and choose the latest)
then place the jar into [YourAndroidSdkDirectory]/tools/lib/monitor-x86_64/plugins/
Restart ADB
Done! now run an emulator, create your database and browse in the ADB to find it on data/data/ ...
Select it and click new the Database buton up right
(you may not see the button before selecting the database file)
Source:https://groups.google.com/forum/#!msg/adt-dev/Jqw9VslC_Vw/YOXWQa1ozmAJ

Related

How to open Android Device Monitor in latest Android Studio 3.1

Recently I updated my android studio, after the update, I am unable to find android device monitor option in the tools section. In the previous update it was there in tools->android->android device monitor. But now in the updated version, it is not present. You can check screenshot of my android studio.
If you want to push or pull your files from devices monitor now android studio offers something better then android monitor. Just take a look at right side of your studio there is an option device file explorer. Open it and you are good to go. Select your device from top dropdown and rest of everything is pretty much the same as it was in android monitor. Below is the screen Shot attached to give you the exact location and idea.
Now you can use device file explorer instead of device monitor. Go to
view > tool windows > device file explorer
screenshot: opening device file explorer in android studio 3.1.3
More details
Click View > Tool Windows > Device File Explorer or click the Device File Explorer button in the tool window bar to open the Device File Explorer.
Select a device from the drop down list.
Interact with the device content in the file explorer window. Right-click on a file or directory to create a new file or directory, save the selected file or directory to your machine, upload, delete, or synchronize. Double-click a file to open it in Android Studio.
Android Studio saves files you open this way in a temporary directory outside of your project. If you make modifications to a file you opened using the Device File Explorer, and would like to save your changes back to the device, you must manually upload the modified version of the file to the device.
screenshot: The Device File Explorer tool window
When exploring a device's files, the following directories are particularly useful:
data/data/app_name/
Contains data files for your app stored on internal storage
sdcard/
Contains user files stored on external user storage (pictures, etc.)
Note: Not all files on a hardware device are visible in the Device
File Explorer. For example, in the data/data/ directory, entries
corresponding to apps on the device that are not debuggable cannot be
expanded in the Device File Explorer.
To start the standalone Device Monitor application, enter the following on the command line in the android-sdk/tools/ directory:
monitor
You can then link the tool to a connected device by selecting the device from the Devices pane. If you have trouble viewing panes or windows, select Window > Reset Perspective from the menu bar.
Note: Each device can be attached to only one debugger process at a time. So, for example, if you are using Android Studio to debug your app on a device, you need to disconnect the Android Studio debugger from the device before you attach a debugger process from the Android Device Monitor.
reference : https://developer.android.com/studio/profile/monitor.html
=> You Can change minSdkVersion 16 And open Device File Explorer
Device File Explorer work same as a Android Device Monitor
See Below Image:
From Android Studio 3.1 Device Monitor available from the command line only.
In Android Studio 3.1, the Device Monitor serves less of a role than
it previously did. In many cases, the functionality available through
the Device Monitor is now provided by new and improved tools.
See the Device Monitor documentation for instructions for invoking the
Device Monitor from the command line and for details of the tools
available through the Device Monitor.
To start the standalone Device Monitor application, enter the following on the command line in the android-sdk/tools/ directory:
monitor
To start the standalone Device Monitor application, enter the following on the command line in the android-sdk/tools/ directory:
monitor
But remember
Most of the Android Device Monitor componenets are deprecated after 3.0
For detail info visit this link
To get it to work I had to switch to Java 8 from Java 10 (In my system PATH variable) then go to
C:\Users\Alex\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64 and run monitor.exe.
jdk max version is 1.8.0_144
then run monitor
As said in "Testing the game on your Android device", I followed these three steps
With the game still running on your device, return to your computer.
Navigate to the directory containing the Android SDK Tools.
Navigate to tools and double click the application called monitor.
This was prompting the following error
I've also tested using cmd and the same error persisted
To fix it, I had to go to AndroidSDKTools\tools\lib\monitor-x86_64 and double click in the monitor application
And then the Android Device Manager just started as normal
You still can run it from File explorer on Windows 10 with the proper path. You just need to go to C:\Users\user\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64 and double click the file monitor.
If you want to use in the cmd just the 'monitor' command you have to add this folder (in my case with android studio 3.4.1 and win10) to your Environment variables. So, press the start button and then type Edit the system environment variabes click it and System properties window should open. Then go to
Environment variables => System variables => path
press the Edit button for path and add the new value
C:\Users\user\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64
click 'Ok', 'Ok' and 'Ok' and restart the cmd window if you had it opened and type 'monitor' and it should open the monitor as well.
Hope it helps!
PD: This answer was based on this answer https://stackoverflow.com/a/55077068/5360905 from Tiago Martins Peres
ADM was deprecated in 3.1 version of android studio and removed from Android Studio 3.2. Android Device Monitor have been replaced by new features and to start Android Device Monitor application in android studio 3.1 and lower, following the commend line android-sdk/tools/ directory:
monitor
If you're looking for the Hierarchy Viewer tool, it has been changed to Layout Inspector:
https://developer.android.com/studio/debug/layout-inspector.html
Android Device Monitor was deprecated in Android Studio 3.1 and removed from Android Studio 3.2
Use Android Profiler introduced in Android Studio 3.0 to measure the cpu utilisation, network, memory etc,. To open Android Profiler: View -> Tool Windows -> Profiler.
Android Device Monitor has been replaced by some new feature which you can find here.
According to developer docs, it's deprecated now. Please follow these docs:
developer link
On Android Studio 3.1 and above, you can push photos to the emulator, by first starting the emulator. Then select “Device File Explorer” from the menu at the top of the screen: View/Tool Window/Device File Explorer
Then look in the folder titled “sdcard” and you will see a folder titled “Pictures”, click on it.
Then right click it and select “Upload” and navigate to the photo on your computer, to the photo you would like to push onto the emulator. The restart the emulator.
See photo below:
example of uploading a photo to emulator
Check this link out.
Open your terminal and type: Android_Sdk_Path/tools
Run ./monitor

How to see the data stored in sqlite in android studio using genymotion as emulator

As i am having AMD processor in my laptop i am using GENYMOTION as an emulator. I have stored the data in sqlite as it is a plugin in android studio. But if i want to see the data using DDMS the file explorer showing nothing. How can i see the data stored in sqlite database using androidstudio and using GENYMOTION. Thanks in advance
Go to Tools -> DDMS or click the Device Monitor icon next to SDK Manager in Tool bar.
Device Monitor window will open. In File Explorer tab, click data -> data -> your project name. After that your databases file will open. Click pull a file from device icon. Save the file using .db extension.
Open FireFox, Press Alt , Tools -> SQLiteManager.
Follow Database -> connect to Database -> browse your database file and click ok. Your SQLite file will opened now.
One of the things that hasn't changed on Android Studio is the Android Device Monitor. so this applies to AS and Eclipse.
1) Download the jar SQLite browser plugin from https://github.com/TKlerx/android-sqlite-browser-for-eclipse/releases
2) Put the jar in: [YourAndroidSdkDirectory]/tools/lib/monitor-x86_64/plugins/AndroidSQLiteBrowser_1.0.1.jar
3) Restart the Android Device Monitor.
4) Select the .db file inside the device(rooted) or the emulator and click on the SQLite browser on the top right corner next to the (+) new folder button.
5) Enjoy!
pull database using adb commands
adb pull /data/data/com.android.packagename/databases/datebase.db
the db will be pulled to current location where terminal is pointing to
then open db using sqliteman
Update Android studio to the latest version 3.0 and we have access to Device File Explorer in :
View -> Tools Window -> Device File Explorer
Official Documenation
To View sqlite database:
install Mozilla sqlite plugin adons or any other sqlite manager plugin to view the sqlite database.
You can use IDEscout. It helps inspect any applications database realtime. You can also edit the database as your need.
All you need is download the IDEscout plugin for android studio. Then for connecting to your project:
Add the dependency to your project level gradle.buid
allprojects {
repositories {
jcenter()
maven {
url 'http://www.idescout.com/maven/repo/'
}
}
}
Add com.idescout.sql:sqlscout-server:2.0 as a dependency to your project's app module:
compile 'com.idescout.sql:sqlscout-server:2.0'
In the onCreate method of your main Activity invoke the method com.idescout.sql.SqlScoutServer#create as follows:
#Override
public void onCreate(Bundle savedInstanceState) {
SqlScoutServer.create(this, getPackageName());
Here are some using views for live data visualization and editing
Depending on the complexity of the data, you can also use an sqlite browser on the device itself. There are various free sqlite browsers for Android (SQLite Manager comes to mind) that will allow you to browse sqlite data on a rooted devices. Since the genymotion device images are rooted, it's easy to install one of these applications and view the data that way. Again, this works best if the data is simple -- it's a bit cumbersome for larger datasets.

How install android sdk plugin from local machine?

I am a developer of Cuba, I can not download the package for Samsung Tablets, I have it on my local machine, but I can not install it, I believe the addon.xml seeks the root of D, as I can create this file? have no idea what format to have?
Sounds like you have addon.xml somewhere saved on your local machine? If so, open it and look for <sdk:url>. Make sure that points to a zip file on your local machine.
Then, run android from your command line. In Tools menu, choose Manage Add-on Sites.... Click on New... and point to your addon.xml file using the file:/// protocol.
After that the Samsung Tablet should show up as an option in your Android SDK Manager for you to install.

How to access local files of the filesystem in the Android emulator?

I want to know whether there is a method to access local files (say text files, web pages) of the filesystem in Android emulator.
I'm using Ubuntu 10.04 for Android development.
You can use the adb command which comes in the tools dir of the SDK:
adb shell
It will give you a command line prompt where you can browse and access the filesystem. Or you can extract the files you want:
adb pull /sdcard/the_file_you_want.txt
Also, if you use eclipse with the ADT, there's a view to browse the file system (Window->Show View->Other... and choose Android->File Explorer)
In Android Studio 3.0 and later do this:
View > Tool Windows > Device File Explorer
In addition to the accepted answer, if you are using Android Studio you can
invoke Android Device Monitor,
select the device in the Devices tab on the left,
select File Explorer tab on the right,
navigate to the file you want, and
click the Pull a file from the device button to save it to your local file system
Taken from Working with an emulator or device's file system
In Android Studio 3.5.3, the Device File Explorer can be found in View -> Tool Windows.
It can also be opened using the vertical tabs on the right-hand side of the main window.
Update!
You can access the Android filesystem via Android Device Monitor. In Android Studio go to Tools >> Android >> Android Device Monitor.
Note that you can run your app in the simulator while using the Android Device Monitor. But you cannot debug you app while using the Android Device Monitor.

What is the path for Android database file?

I am trying to find the path for the android database files on Ubuntu 10.4, because I want to access with SQLite Browser. Someone can tell?
In Android, the database that you create for an application is only accessible to itself; other applications will not be able to access it.
Once created, the SQLite database is stored in the /data/data/<package_name>/databases folder of an Android device.
How to see the database file:
If you are using Eclipse:
switch to DDMS perspective - > File Browser -> Browse to data/data/your_package_name
folder. There you would see your database.
(To open DDMS Perspective, go to window -> open Perspective -> DDMS)
And also you can use the adb shell to cd to that directory and open the db with sqlite3.
You can also copy files or database from Android devices or from emulator by using adb pull , for more info refer this: http://developer.android.com/guide/developing/tools/adb.html#copyfiles
The path of your application database?
You will have to pull it from the emu/cel.
I would recommend using questoidsqlitemanager:
Questoid SQLite Manager is built on
top of Dalvik Debug Monitor Server
(DDMS). This tool is intended for
Android developers to manage SQLite db
file on Android device emulator.

Categories

Resources