Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is with <code>Database file</code> size. You can make a <code>Zip</code> of your <code>Database</code> file and then copy it to your local path from <code>Assets</code>.</p> <p>Here is the link: <a href="https://stackoverflow.com/questions/5945059/how-to-use-sqlite-connection-from-asset-folder/5950967#5950967">Copy Db File From Assets</a></p> <p>Now, in that code replace the <code>copyDataBase()</code> function with the below one.</p> <pre><code>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)) &gt; 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)) &gt; 0) { nOutputStream.write(buffer, 0, length); } nOutputStream.flush(); nOutputStream.close(); nInputStream.close(); // Close the streams mOutputStream.flush(); mOutputStream.close(); mInputStream.close(); } catch (Exception e) { e.printStackTrace(); } 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()) file.delete(); } } </code></pre> <ul> <li>Here <code>DB_NAME_ZIP</code> is the <code>Database Zip</code> file what you put in <code>Assets</code> folder like <code>Android.zip</code> but it actually contains <code>Android.sqlite</code> or <code>Android.db</code>.</li> </ul> <p>I hope this one can help you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload