SQLite Database from Internet

I have a rather large database that ships with my app. I'm having a lot of trouble getting it to properly create itself on the local device, so I figure with the issues and it being so large, it might make more sense to host it on a server and work with it from there.

The database is 40 MB or less. What is the best way to manage this with it hosted somewhere?


The problem is with Database file size. You can make a Zip of your Database file and then copy it to your local path from Assets.

Here is the link: Copy Db File From Assets

Now, in that code replace the copyDataBase() function with the below one.

private void copyDataBase() throws IOException {
    try {
       InputStream mInputStream = mContext.getAssets().open(DB_NAME_ZIP);
       String outFileName = DB_PATH + DB_NAME_ZIP;
       OutputStream mOutputStream = new FileOutputStream(outFileName);
       byte[] buffer = new byte[1024];
       int length;
       while ((length = mInputStream.read(buffer)) > 0) {
          mOutputStream.write(buffer, 0, length);

       ZipFile mZipFile = new ZipFile(DB_PATH + DB_NAME_ZIP);
       InputStream nInputStream = mZipFile.getInputStream(mZipFile.getEntry(DB_NAME));
       OutputStream nOutputStream = new FileOutputStream(DB_PATH + DB_NAME);
       while ((length = nInputStream.read(buffer)) > 0) {
          nOutputStream.write(buffer, 0, length);

       // Close the streams
    } catch (Exception e) {
    } finally {
       //Delete Zip file to minimize memory usage
       final String mPath = DB_PATH + DB_NAME_ZIP;
       final File file = new File(mPath);
       if (file.exists())
  • Here DB_NAME_ZIP is the Database Zip file what you put in Assets folder like Android.zip but it actually contains Android.sqlite or Android.db.

I hope this one can help you.

Need Your Help

How to serialize/deserialize an object loaded from another assembly?

c# serialization deserialization

I want to serialize/deserialize an object that has been instantiated by another object loaded from an assembly:

ImageData.data on Internet Explorer 11 ( Windows 8.1 Enterprise vs Windows 8.1 Pro )

javascript html5 internet-explorer cross-browser compatibility

I have been developing a Web App which makes use of Javascript's ImageData object. This object has a data property which is expected to return a Uint8ClampedArray. However, when using the default b...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.