Note that there are some explanatory texts on larger screens.

plurals
  1. POimport a table into an existing SQLite database
    primarykey
    data
    text
    <p>In my app, at first launch, I download a pre-populated database from the web. (rather quick)</p> <p>And every x times, I need to update one table in the database. I don't need the old entries so I can delete them.</p> <p>Here is what I do: I delete all the content of my table. And then I get a csv file with my data from the web and I used Statement (to optimize) to do lots of inserts... But, it takes several minutes (thousands of rows).</p> <p>So, I was wondering, since I don't need the old entries, how about dropping the table and importing the new one from the web? This way, I would avoid the inserts and it should be faster.</p> <p>Is that possible?</p> <p>EDIT:</p> <p>Here is my code, please correct me if it can be optimized:</p> <pre><code>int size = 5; SQLiteStatement statement = myDB.compileStatement("insert into " + TABLE + " values(?, ?, ?, ?, ?, ?)"); String data[]; String line = null; int size = 5; //... //some code //... myDB.beginTransaction(); while((line = bufferedReader.readLine()) != null) { data = line.replaceAll("'", "''").split(",", -1); statement.clearBindings(); for(int i = 0; i &lt; size; i++) { statement.bindString(i + 1, data[i]); } statement.bindString(size + 1, deadline); statement.executeInsert(); } myDB.setTransactionSuccessful(); myDB.endTransaction(); </code></pre> <p>And just to clarify, I don't want to DELETE my database since I want to KEEP all the other tables in my database, that's why I'm asking if it is possible to import (and replace) only one table into a database with other tables. </p>
    singulars
    1. This table or related slice is empty.
    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.
    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