0

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.

5
  • are you have the sqlite Database ??? and need to using it in your android app ? Commented Jan 15, 2014 at 23:35
  • I don't know much about Parse.com, but what I did in a similar project was on server side create the sqlite database file, so when the android and iOs app starts for the first time, they download the database from the server. Commented Jan 16, 2014 at 0:07
  • @CarlosT I want to bundle the database with the app rather than downloading after the user opens the app. Do you have any ideas on how to do this? Commented Jan 16, 2014 at 15:26
  • @mohammedmomn I have the sqlite database that core data from Xcode created but I don't know if I can use it with my android app. Commented Jan 16, 2014 at 15:27
  • you can use sqlite file and import it in your project and work with it like as you create it in your code when you put sqlite file in your assest and working with it Commented Jan 16, 2014 at 18:04

2 Answers 2

1

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.

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

1 Comment

Basically this is what I ended up deciding to do. Another good tutorial is androidhive.info/2013/09/…
0

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.

1 Comment

Makes sense. Do you know if I can export the database from my android app to my computer? Basically I want to bundle the database with the app rather than downloading after the user opens the app. Do you know if there is there a good way to do this?

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.