I am new to Android and Java. I am creating an Android application in which I will be collecting data and also importing data from server to Android.
I wish to store the data imported into SQLite tables. So I created two tables as per my requirement. This tables should be created when ever app is opened and should be cleaned when ever the app is CLOSED not switched. For this I am dropping the tables in onOpen(), it is working fine in Emulator. I am able to see the values in DDMS-Data.
Now I am trying to implement it on android mobile and I am looking at data folder in DDMS for the device. But I don't see any tables. The folder remains empty.
Sometimes its restricted to view table inside data folder for Device as manufacturer by default have not given permission to view it.But your tables do exist inside your data folder.
You can check by opening it inside your app if you want to confirm. You can definitely drop your tables and it will get cleaned when ever the app is closed don't worry about it. You have to root your device to get permission , which will take away your device warranty.
You cant check Database table from Device by ddms utility. cause it wont be listed there, but you can check data by applying a select query, wherever you want to debug.
Some devices needs to be 'rooted' in order to be able to access the data folder. You can read more about this process on wikipedia http://en.wikipedia.org/wiki/Rooting_%28Android_OS%29 However if you need it only to see your tables it's not recommended to do it.
Related
I'm working on an app that uses sqlite to store data and I need/would like to view the tables in the app to be sure things are being added correctly and the content exists. How do I review the tables and their data being used in my app.
I'm using a Nexus 7 with 4.4 on it for testing the app.
You have basically two choices.
Run the app in the emulator, then "pull" the db to your dev machine and use a tool such as SQLite Expert Personal 3 to view the db.
Create your db in the external storage instead of internal. Then you can use your USB connection to "pull" the db.
I guess I can add (3): add code to dump your tables to the log file.
I don't know this can solve your problem or not but installing THIS plugin into eclipse help me a lot to view database table and content inserted.
Does anyone know of Android code I could embed directly in my app, such that I could browse my SQLite database directly from within my app?
If not, how about code that reads the SQLite metadata, and dumps table and column names and data to the log? (In JDBC, I'd use databasemetadata to get table info, and then table metadata to get column info...)
I know I can browse on an emulator, and I can copy the db off the device and then point a db browser at it. But this would be a lot more convenient for me during development. This would of course be used only for test databases with tiny amounts of data. Any suggestions?
Have a look at this question: browse data in Android SQLite Database It may not be exactly what you're asking, but may be sufficient for your needs.
Alternatively, there's a sqlite database browser app in the market, which you may be interested in (I haven't tested it myself): https://market.android.com/details?id=com.xuecs.sqlitemanager&hl=en
I think this is what you are looking for .
Using the library in the link below you can browse your app database from your app https://github.com/sanathp/DatabaseManager_For_Android
With this library you can manage your app SQLite database from you app itself.
you can view the tables in your app database , update ,delete, insert rows to your tables .Everything from your app.
Its a single java activity file ,just add the java file to your source folder.When the development is done remove the java file from your src folder thats it .
It helped me a lot .Hope it helps you too .
You can view the 1 minute demo here : http://youtu.be/P5vpaGoBlBY
I'm developing a content provider which stores its data in an SQLite database. During development, I need to change the schema, or delete the database entirely and have it rebuilt (I'm not upgrading the database at this stage of development).
I found the database file, stored at /data/data//databases/app_db . When I pull it to my desktop machine, I can use SqliteSpy to see its content and all is well. However, when I delete it, it doesn't always get really deleted. Although I can't see the file in DDMS or ADB, my application still sees it.
I tried to make sure my application and service aren't up when I delete the file, but it doesn't seem to help. In about half the times I delete the file, I need to restart the emulator for it to have effect.
What could be preventing the file from being really deleted?
Itay.
I've seen this issue too when was writing unit tests for my ContentProviders. You need to make sure you've killed the process that hosts ContentProvider that uses that specific database file. And only than delete it.
First I want to say thanks to everyone that reads this. Stackoverflow is an amazing site and you guys help me out with answers everyday in the form of questions already submitted. You all rock!
My problem:
I'm working on a database app that I'd like to back up the database at certian points so I can save the data I've collected in database over time, during development. So to save the database to accessible memory I've followed this page:
How can I pull databases off my android onto my desktop?
..and the above code is working great in the emulator (I can use DDMS to pull the copy of the database to my PC and view it using SQLite Database Browser). However when I run it on an actual device, SQLite Database Browser can't read it. To extrapolate, the copy is being created just fine on the SD card, but when I copy to my PC from my device and view it, I get nothing, SDB can't understand it or something. However when I use an emulator, I can copy it off using DDMS and view all the tables just fine with SDB.
Using WinMerge to compare the two raw database files (one generated by the device, one generated by the emulator both running the same code) I can see there are formatting differences, but nothing that looks corrupted, but I'm not 100% sure. The android metadata and SQL sequence tables appear to be in there (albeit in different orders), as well as my custom table.
Do you guys have any suggestions on how to debug this? I'm not sure where to start since it seems to work perfectly on the emulator. Also, I've run the emulator at the same android release (2.3.3) as the device, so I'm am pretty sure they are using the same SQLite engine.
Thanks,
Matt
I'd try opening this database with different SQLite clients.
If that doesn't work, the next step may be to try finding an SQLite database file validator and/or to run the standard SQLite client in debug mode (but to be honest, I don't even know if those two last options are even possible).
I create only a table from code but inside still empty. I instead insert data by pull a file out and insert by SQLite Browser when run the emulator then, put it back to the data/data/package_name/file.db with this solution, after run the program I can see the list of information in Emulator. But moving the application on a real device, I cannot see any list of information on a real device. How should I do?
Because my application just provide the data to user, so user has no need to add or edit data to the database. In addition the data don't need to change very often. that's why I use SQLite Browser to insert data.
I know that there are some security constrain in (not-rooted) device. However, are there any suggestion about the solution.. How should I edit my code?
You can package your database in your res/assets/ folder and then copy it onto the /data/data/YOUR_APP_FOLDER/databases if the database does not exist (i.e., first install) or if it's older than the file in the assets folder (i.e., updated apk).
This post has a full working example: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/