using an exported sqlite database in Android - android

I want to use my own sqlite3 database in my android project.
I created this database with command-shell line (windows) and exported it with SQLite Database Browser (sql format).
I followed this tutorial and my database can't be open :
go here to see since i can't post image
My package is org.opencv.samples and my DBName is "maif" placed in /assets directory.
So it seems that my exported database is incorrect, can someone helps me ?

I suggest to use this helper to solve your problems: https://github.com/jgilfelt/android-sqlite-asset-helper

I don't believe you can transfer an external database through the file system to Android unless you have a rooted phone. If you have to transfer data you need to use data transfer via HTTP using XML/JSON.

Related

Access SQLite DB from IntelliJ for Android

How can I view the DB in IntelliJ to view its content and perform operations on it. Now I have created my tables etc but i have no idea what data is on the DB and I do not want to create queries in java to check it. seems like a slow workflow so ill wait til I know how to access the db that resides on the Android emulator im using.
Is it possible?
You can also use Stetho. A nice debugging tool from Facebook.
Just simple to use, initialize it in your Application class and access your sqlite and even shared preferences from Google Chrome's developer console.
You can create a database file outside of Android and use any tool to create and read it.
Then, you place it in the assets folder and setup your code to read the database from there instead of private app data. Caveat here is that a copy will be made from the assets folder to the app data, so any updates within the app won't be mirrored to the database file in the assets folder.
I believe you can access the DDMS window in Intellij/Android Studio and there is a Database Explorer there
see #alexsimo's answer.
Without root you cannot access your database on your device, unless the file is created with a+r permissions.
Since that is something that is unrelated to the issue, you can just search in plugin.jetbrains.com for sqlite and get a variety of plugins.

Edit sqlite file outside the app

For testing, I wanted to manipulate the sqlite database for my Android app. I copied the database file to my laptop, edited the file with the Sqlite manager plugin for Firefox, and copied the file back to its directory.
I thought that would work, but the app crashes, because it can't open the database. The ownership and permissions of the file is like before.
Can someone explain to me why it won't work, or suggest how I could do instead?
1.Use Sqlite browser..download here
2.Pull your database to your computer..
3.Edit the database using sqlite browser
4.Delete the database from eclipse then push the edited database to your aplication Run the app to see the result

How do i check my SQLite database values in eclipse?

I created a app and added some tables, columns and some info in it and i want to check it, how do i do it?
Switch to DDMS perpective(Window > Open Perpective > DDMS).
Find out your database's db file in file explorer. Select it.
Export it by clicking on the button in the top right corner of the UI.(ie; Pull the file from from the device)
Use SQLiteman to view the data.
Hope it helps.
If you are running your app on the phone, you cant access your internal storage unless it is rooted. If that is your case simply run the app on a virtual device, then go to DDMS perspective, from there data/data/yourapplication/database/urdb.db then pull the db on the your computer and explore it with the tools stated above.
you can query the database from your android code to do this.
check the link http://codinglookseasy.blogspot.in/2012/08/sqlite-database.html where you can find creating table , inserting data into tables and retrieving it . Or use SQLite Database Browser http://sqlitebrowser.sourceforge.net/ to check the values without using the code
use Sqlite Database Browser tool to see the your Sqlite database.
Go to the DDMS and export your application database and open this database in Sqlite Database Browser
This post on how to access sqlite database on Android, will help you out. There is one mozilla plugin which can also help you to see the database.
I believe that Motodev Studio allows for database browsing.
http://developer.motorola.com/tools/motodevstudio/?utm_campaign=mhp01092012&utm_source=mhp&utm_medium=mws
Or you could just export the database to your desktop, for example, and then browse it with the Firefox SQLite plugin.

Android - How to find my rooted path

I am creating a new app using phonegap (html and javascript) and am using an SQLite database. Due to phonegap limitations and my need for a dynamic database I am following these steps:
1 - creating an external database
2 - exporting this with the .apk file
3 - on app load I replace the phonegap database with my database
The issue I am having here is working out whether 'LocalFileSystem.PERSISTENT' or TEMPORARY. It looks like it is persistent. However, I am not sure how I can root my device allowing me to access and replace the database within the relevnt 'LocalFileSystem.PERSISTENT' section.
Thanks
By default your SQlite database is created at:
/data/data/Your Package/databases/your database
For using already created database see this.

How do I manually insert a database into a Android project?

The database file is identified by Dalvik when I insert it via the Dalvik Debug Monitor Server (DDMS), but when I add the database to the project assest it doesn't even upload to the device (as I can see through the DDMS). How to fix it?
Adding a sqlite db to the assets folder will not make it available for you to use it.
Your db should be copied to /data/data/YOUR_PACKAGE/databases/ on the first run.
Check this link.

Categories

Resources