2

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

3
  • It's like in every db, you should define the tables, the keys, and just read the data. Have you checked github.com/praeclarum/sqlite-net ? Commented Jan 14, 2019 at 17:25
  • Have you used an ORM for the Android version? If so, you should check how the tables and columns are named and set up the ORM for your Xamarin.Forms App accordingly. Your question is a bit hard to answer, since it lacks details about your current SQLite setup. If you added the structure of your DB or the classes the data is mapped to, i twould be easier to give an answer. Commented Jan 15, 2019 at 5:57
  • @AlexCatana I have done a similar implementation recently kindly add a little bit more information about your current SQLite so I can answer this properly Commented Jan 15, 2019 at 9:32

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.