Dragging and Dropping a SQLite database between projects - android

I see a sqllite database in another application, why can't I just just drag and drop from that application to mine in the eclipse environment? that way I can use data already in that database?

Android doesn't do too well with using an sqlite database file directly. Generally the way to go around it is to package an sqlite database as a resource and on first create of the app to load that resource and then connect to it and then copy all the data out of it. The downside of this is you are essentially doubling all your data.
If you are the publisher of the other app then you can list the database as a shared database to share between your apps.
Share SQLite database between 2 android apps?

Noone has written an Eclipse plugin that does that. You can write one if you feel it is both useful and worth your time.

Related

When I use a sqlite database as an asset can the database still be used/viewed by another program?

I am working on my capstone and I need to create two programs using two different languages that use a single local database. I am making a chore manager that will be a windows program and an android app. I figure out how to use sqlite for the windows app, but I cannot wrap my head around using an existing database with android studio. I need the app to be able to read existing data and display it and then based on some conditions edit the data.
If I add the database as an asset will the data a user changes using the app be usable by another windows program?
Here's my opinion: "Don't use SQLite for this." Use a regular shared database that you can (securely ...) access from both environments.
SQLite databases are files, accessed through the file-system. They are most commonly used where the data won't be shared, because, like any "shared file" database of aeons past, they are always subject to corruption if someone (or the operating system, or the network ...) does anything wrong. Whereas a conventional client/server database doesn't have these problems because it controls the data while it talks to you.
SQLite is a marvelous tool for storing structured information on a device. I've deployed many dozens of "boutique" websites which store their page-information that way. But, I think, it's not the right tool for this job.

Android App: can I use iOS sqlite? If not, how do I create a local database from a database in the cloud (Parse.com)?

I am making an Android version of an iOS app that I already have. I want to use a local database so that the user can use most the app offline.
Initally I thought I could use the sqlite database created by Core Data in Xcode, but as I am reading things online it seems like this is not possible. Is this true? Or is there a good way to export it to something Android could use?
If not, I want to create a local database with values from a database on the cloud(I use Parse.com). How can I do this? The data on the cloud doesn't change very often (maybe twice or thrice a year) if that makes any difference.
This is a good tutorial to handle preloaded databases:
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Essentially, once you have your precreated database, put it in your assets directory in your apk. Then on first app use, copy this from assets to "/data/data/YOUR_PACKAGE/databases/" directory.
You have to create the database by code in Android, using a DatabaseHelper http://developer.android.com/guide/topics/data/data-storage.html#db. If you want to use your already created database you will have to export it to SQL statements and then "import" them to your application.

Browsing Android SQLite database within application

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

How to copy populated sql database to phone's memory on first launch of the app?

I have an android app created using html5, jquery and phonegap and it stores entries into sql db. I already have populated all data into the database. Now, my question is how can I save this populated db and pack it with the apk file so that it'll just copy it to phones memory when the user installs the app?
I used Chrome and that is where I populated the data.
As far as exporting the data you have in your already populated database, I would refer you over to this post where they walk through how that might be done.
Once you have a dump of your database, I believe the easiest is to just manually populate the database the first time the app loads. If you use a library like html5sql.js you will be able to do this easily and in basically one step.

Storage of Static data within android app

I am currently developing a simple info app on various university campuses. I want the app to operate predominantly in an offline state thus I want to store all my information locally. The data within the app will not be subject to any change thus I was wondering what the best (practice) method was to store such data? Basically should I be storing the info in a SQLite db, java file or xml?
The answer depends on your requirements, but because of the built-in integration with SQLite, the easiest will probably be to just use SQLite, plus you get the benefits of a relational database. You can refer to the Notepad tutorial for a start.
It depends on the data you have. If it is largely text I would store it in an android string resource file. If it is somehow structured and has IDs and relations store it in a database.
We had a University project requiring a local database on an android phone. What whe did was to use SQLite to write on a database stored on the memory stick. (We couldn't find the right permissions to write directly on the file system)
Check the API website for the android.database.sqlite package first.
And here for a nice tutorial :
http://www.devx.com/wireless/Article/40842

Categories

Resources