i have some sample code i have been playing around with. Basically im just reading from a csv file and writing into a table. Can the below be improved so that it goes faster seems quite slow
public void impcusdata() throws SQLException, IOException {
try {
String UnitID = getUnitID();
FileReader fr = new FileReader("/mnt/sdcard/CRM.CSV");
// Put the file into the buffer
BufferedReader in = new BufferedReader(fr);
db.execSQL("DELETE FROM " + CUSTOMER_TABLE);
// Create a new string to hold the data
String data = "";
// Create the strings executing SQL commands for the data to be
// inserted
String InsertCustString = "INSERT INTO " + CUSTOMER_TABLE
+ " VALUES(";
String InsertEndString = ");";
// If there is any data in the .CSV file then read it.
while ((data = in.readLine()) != null) {
// String the results to the SQL database
db.execSQL(InsertCustString + data + InsertEndString);
}
} catch (SQLiteException ex) {
String Shaw = ex.getMessage();
}
// log entry to the LogCat file
Log.v(TAG, "Customer Table has been updated");
}
Yes, using SqliteDatabase.beginTransaction() with setTransactionSuccessful() and endTransaction() you can combine several queries.