-2

What is the best way to download .db from url and use it in my app?

Thanks for help. I was looking a lot in google but no one method helped me.

I'm using android.database.sqlite.SQLiteDatabase; and android.database.sqlite.SQLiteOpenHelper;

Yas
  • 351
  • 2
  • 17

1 Answers1

2

What is the best way to download .db from url and use it in my app?

The same way you would download anything from a URL: use an HTTP client API, such as the built-in HttpUrlConnection or third-party libraries like OkHttp.

Download the database to a location that you get from calling getDatabasePath() on Context, to store it in the default directory that SQLiteOpenHelper will use.

After the database is downloaded, you can open it using SQLiteOpenHelper.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Can you show me an example how to save data from web using okhttp? I don't understand it and i can't find it on Web. – Yas Oct 03 '15 at 16:57