How to copy sqlite base to android emulator? - android

The sqlite base file is stored in path data/data/my-package-name/databases/mybase.db
(Where does Android emulator store SQLite database?)
Sometimes, i get this file on a remote real device and i would like to copy it to android emulator on my Android Studio for debugging. In other words, i want that my application on Android Studio uses this base. How can i do it?
Another possibility: how to copy this base to a my real device who is connected to PC by USB cable
thanks a lot,
regards

Start your emulator.
Open Device File Explorer (a tab button at the bottom right side of Android Studio).
Go to the folder data/data/my-package-name/.
If there is no subfolder databases then create it by right clicking on the my-package-name folder and then New->Directory where you type databases and click OK.
Now right click on the folder databases and click Upload....
Navigate to the SQLite file that you want to copy, select it and click OK.

Related

Android : View SQLite Database

I'm running Android Studio 1.3 and working on tutorial app. I'm using GenyMotion for testing purpose. I have written some code to create a database. Now I want to see whether that database has been created or not. If yes then where it is stored. In Eclipse we used to have DDMS Monitor but no such thing is present in Android Studio. So How to do so?
Easiest way is using Android Device Monitor to get the database file and SQLite DataBase Browser to view the file while still using Android Studio to program android.
1) Run and launch database app with Android emulator from Android Studio.
2) Run Android Device Monitor. How to run?; Go to [your_folder] > sdk >tools. You can see monitor.bat in that folder. shift + right click inside the folder and select "Open command window here". This action will launch command prompt. type monitor and Android Device Monitor will be launched.(There are other ways to open this too. Search it)
3) Select the emulator that you are currently running. Then Go to data>data>[your_app_package_name]>databases
4) Click on the icon (located at top right corner) (hover on the icon and you will see "pull a file from the device") and save anywhere you like
5) Launch SQLite DataBase Browser. Drag and drop the file that you just saved into that Browser. (You can view the database using any SQLite browser of your choice)
6) Go to Browse Data tab and select your table to view.

I am working on Eclipse Juno, and when I click on Windows > File Explorer, it is not showing the data and other folders

I was trying to establish database connectivity in Android. According to the tutorials I was referring to, it should show me some folders when I click on file explorer option in Windows tab. But no folder is shown there. Am I doing something wrong or is something wrong with the SQLite in my IDE?
Is the emulator or device is connected and running. If not please connect and click on that device from device list and then click file explorer.
For reference:
http://developer.android.com/tools/debugging/ddms.html

Database not visible in DDMS folder when real device used instead of emulator

I am creating a sample application which will create a database, Inserts data and finally displays it in a spinner.
For testing I am using my android phone instead of Emulator (As I am fedup with its slow response).
My problem is application running succesfully but spinner is not displaying any result also I am unable to view any folder structure under DDMS->data.
I am confused whether database created or not, Please suggest me how to view the database if we use real device instead of emulatpor
You must start you emulator, browse the emulator files in the DDMS view then select File explorer then go to data > data > com.your.package > databases > your_database_name and a new tab will appear with your data! It won't work on a real device.
You can even pull/export the database and analyse it more effectively with SQLite Browser
enjoy !
You can't get SQLite databse file from an Android real device if it is not rooted. Because to access the data folder of your application you have to provide the permission for it.
But you can run your application in an android emulator and following is the way:
From DDMS, in Devices menu select your emulator.
You can see data folder in File Explorer.
Path is: data->data->Application Package Name->Databases->Database Name
U just goto File Explorer
Windows>show view>File explorer>data>package>database name to see your database
in emulator

How to view data saved in android database(SQLite)?

I am able to view the database from eclipse(from file explorer), but I want to view the whole detail, I mean the data that I have inserted, which I am unable. And my complete Android installation has made on F Drive.
You can access this folder using the DDMS for your Emulator. you can't access this location on a real device unless you have a rooted device.
You can view Table structure and Data in Eclipse. Here are the steps
Install SqliteManagerPlugin for Eclipse. Jump to step 5 if you already have it.
Download the *.jar file from here
Put the *.jar file into the folder eclipse/dropins/
Restart eclipse
In the top right of eclipse, click the DDMS icon
Select the proper emulator in the left panel
In the File Explorer tab on the main panel, go to /data/data/[YOUR.APP.NAMESPACE]/databases
Underneath the DDMS icon, there should be a new blue icon of a Database light up when you select your database. Click it and you will see a Questoid Sqlite Manager tab open up to view your data.
*Note: If the database doesn't light up, it may be because your database doesn't have a *.db file extension. Be sure your database is called [DATABASE_NAME].db
*Note: if you want to use a DB without .db-Extension:
Download this Questoid SqLiteBrowser: http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip
Unzip and put it into eclipse/dropins (not Plugins)
Check this for more information
Dowlnoad sqlite manager and install it from Here.Open the sqlite file using that browser.
Try this..
Download the Sqlite Manager jar file here.
Add it to your eclipse > dropins Directory.
Restart eclipse.
Launch the compatible emulator or device
Run your application.
Go to Window > Open Perspective > DDMS >
Choose the running device.
Go to File Explorer tab.
Select the directory called databases under your application's package.
Select the .db file under the database directory.
Then click Sqlite manager icon like this .
Now you're able to see the .db file.
I recommend the firefox plugin(SQLLite Manager) if you always use firefox.
Here is the link
If you are able to copy the actual SQLite database file to your desktop, you can use this tools to browse the data.
1. Download SQLite Manager
2. Go to your DDMS tab in Eclipse
3. Go to the File Explorer --> data --> data --> "Your Package Name" --> pull file from device 4. Open file in SQLite Manager.
5. View data.
Open DDMS than in DATA>DATA>"Select your package like com.example.foo"> than select your database folder than pull that data
in eclipse you can see the pull an push icon on top right side ...
If you don't want to download anything, you can use sqlite3 tool which is provided with adb :
Examining sqlite3 databases from a remote shell
and :
Command Line Shell For SQLite

How to import SQLite database in Eclipse IDE

I am creating an Android Application and I recently downloaded a SQLite Database Browser. I have created a database which has 3 tables. Now I'm wondering on how to import the created database into Eclpise IDE.
I hope someone could help..
You have to put your SQLiteDatabase file inside the assets folder of your project.
Open the DDMS perspective in Eclipse. There you should have a tab saying File Explorer (remember to select your emulator device in the Devices tab). You can use this to browse to your database file on the emulator. The database should be located in \data\data\[name_of_your_app]\databases. You can then select the database file (.db) and copy it to a local folder (there is a Pull a file from the device button in the upper right corner of this tab).
Also note that this is only possible on an emulator, since you're not allowed to browse the content on a real device this way.

Categories

Resources