Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to import my sqlite database into Android
    primarykey
    data
    text
    <p>Following the tutorial <a href="http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/" rel="nofollow">here</a> I've been trying to copy this and I keep getting errors on the Outputstream declaration line.</p> <p>My following code is here:</p> <pre><code>private void copyDataBase() throws IOException{ System.out.println("copyDatabase Start"); //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); System.out.println("copyDatabase: InputStream Set"); // Path to the just created empty db String outFileName = "/data/data/com.example.sqllitedb_user/databases/"; System.out.println("copyDatabase: outFileName:" + outFileName); //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); System.out.println("copyDatabase: FileOutputStream set to above name"); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))&gt;0){ myOutput.write(buffer, 0, length); } System.out.println("copyDatabase: byte buffer thing ran" ); //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); System.out.println("copy Database complete"); } </code></pre> <p>I see some other people have had the same problems and I was wondering what the solution is.</p> <p>Is there another (easier) way to import and access my own sqlite table?</p> <p>IGNORE THIS POST - Turns out I forgot to call the initialisation method on my main activity.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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