Migrate sqlite database from android studio app to Xamarin.Forms app - android

I've been developing an android app for the last year or so in android studio. It has been in the play store since October and quite a few people are using it.
I have received many requests to create the same app for iOS and so after a lot of research I've settled on xamarin forms as it will be easier to code (as I'm familiar with c# and xaml) and less work to maintain the app for both platforms at the same time (even though it will take a while to port the code over).
The android app is using sqlite for data persistency and the xamarin version will do the same.
My question is, how could I port the sqlite databases of existing users to the new app once it is released? Is there a way to define the table/column names the same as I have set them in the android studio version?
Currently the app has a feature to export the database to the Downloads folder and the xamarin.forms app will import it from there.
I haven't seen anyone in any tutorial explicitly define the table and column names in their xamarin.forms sqlite implementation so I'm a bit worried to take the leap.
Is there a way to ensure that existing databases will work out of the box once imported in the xamarin.forms app? If not, could someone please point me towards a piece of code that will migrate data from one dB to another?
Thank you in advance for your time.
Regards

As I got a bit more familiar with the SQlite package in Xamarin.Forms, turns out that the answer is as simple as adding the [Column("my_column")] attribute above the property in the model. This way it will name the column to whatever is specified in the brackets and I can make sure it matches the database schema I have in my current project from Android Studio.
a bit of a "duh!?" moment here for me but thank you to all who have taken the time to answer!

Related

Phone gap sqlite plugin vs websql

I have been working on a simple database application for a small phonegap project. I have successfully implemented a websql database that stores a single table with some basic data. Recently I have been reading that this method is being phased out gradually due to some limitations. There seems to be an alternative using a webkit plugin for phonegap. This interfaces between the sqlite database on the phone and the front end.
So my question boils down to: What is the best practice when developing a database application using phonegap? Which technologies would you suggest? Any help is much appreciated. Thanks
Hi if it is larger database then go for Native sql plugin, if it is small then use HTML 5. HTML database They are fast, flexible and never expire.all of the queries are run via JavaScript, they persist until manually removed. but if the DB size is so large application must hang, so for much larger DB manipulation you can use Native Sql.and HTML 5 db Not ideal for sensitive information like password.
refer this may help you.
I suggest you to use a sqlite plugin. I have an application since android 4.0 using websql, and now, on the devices using android 4.4, my application stops working.
Don't commit the same error that I do. Use android native sqlite instead html5 websql.

How to Connect Database in Phonegap API for Android and iOS

Hello I am developing application using phonegap, I want one Html page and i will put the button.
On click of that button it must fetch my sqlite3 database and just simple it must display to my next or same html page..
depending upon query.
Please anwer my question and what IDE I must use.....
To use sqlite3 on a phonegap application, you will need this Phonegap-SQLitePlugin.
However, the plugin has been designed for Phonegap 1.7 so you might need to upgrade it.
You don't need to use any plugin, as webkit already has sqlite available. I have written a data access framework to sqlite in phonegap, please check here.
It's quite easy to use, you don't need to write any sql scripts. It works very like asp.net entity framework.

How to build a simple NFC based Android app, read only

Here's a loaded question for you guys. First off, what background I have is in Visual Studio 2010 and C#. I have all the code as far as SQL queries and such already written in a PC variant of this application. I haven't made an Android app before, and I don't have experience with java. I'm just praying it isn't too far a leap from C#.
What I want to do is make a very basic app which would be called when the NFC scanned a tag. The app would then push the contents of the tag to an SQL database. There doesn't need to be much, if any, user interface.
As of right now, I've installed the Eclipse IDE with the Android SDK. I went through the tutorial and made the Hello World app then ran it on my device (Nexus 4 running stock 4.2.1).
I've been trying to find tutorials and such, but I need something fairly basic as I'm not familiar with this environment yet. Any pointers on where to start or how to go about making this would be greatly appreciated.
To get started with the NFC app creation:
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html
some tutorials for working with SQL databases:
http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/
http://www.codeproject.com/Articles/119293/Using-SQLite-Database-with-Android

Is it possible to create an Android database without external tools?

I have been searching for this for the past few days and every tutorial I see needs for me to use an external package. Is there anything built into the Android SDK that would allow me to create a database? I thought I saw something on it a long time ago, but I can't find anything to back that foggy memory up.
Do you mean creating SQLite database? The SQLiteDatabase::openOrCreateDatabase() will create sqlite database and it's part of the android SDK:
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

Managing an Android database

I'm looking to implement my first Android database, but I have so many questions which (I believe) are unanswered by all the tutorials I find.
Here are my needs:
- I want my application to have a database that is persistent. If my application closes and launches again, there is already a database to pull data from. It does not create a new database every time the application is killed and re-launched.
- I want to implement versioning. Say version 1 of my application has a few tables. I release version 2 and I want some sort of script to run to add new tables I've added or modify old tables I've added; and so on and so forth. The application has to know whether the database is at a particular version (which means I'll need a table in the database) so it knows whether to run this script.
Could someone provide me with some resources so I can figure out how to do what I need? Thank you
Look for sqlite+android+tutorial:
http://www.hdelossantos.com/2009/12/23/creating-a-sqlite-database-in-android/
http://www.hdelossantos.com/2010/01/07/using-a-sqlite-database-in-android/
and some more:
http://www.google.com.hk/search?sourceid=chrome&ie=UTF-8&q=android+sqlite+tutorial
There is also a sample in the sample programs that come with the SDK, i.e. the Notepad app.
And the official developer api doc - but that's more as a reference, not as tutorial:
http://developer.android.com/reference/android/database/sqlite/package-summary.html

Categories

Resources