I'm trying to take a CSV file and importing that data into Android's SQLite3. The app runs fine without any SQLite error in the LogCat. I'm not sure why the data isn't being inputted. I made sure that the program actually tries to do the insert execSQL by deliberately causing a SQLite syntax error in the insert command and it showed up on the LogCat. So it does find the CSV file and it does get to the insert execSQL. I'm just not sure why it isn't inserting.
private static final String CREATE_TABLE_MOVIES = "CREATE TABLE movies (_id integer primary key autoincrement, title text not null, year integer not null, director text not null);";
public DbAdapter(Context ctx){
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
mContext = ctx;
this.mDb = getWritableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_MOVIES);
try {
BufferedReader in = new BufferedReader(new InputStreamReader(mContext.getAssets().open("movies.csv")));
String line;
while((line = in.readLine()) !=null) {
String[] RowData = line.split(",");
moviesID = RowData[0];
moviesTitle = RowData[1];
moviesYear = RowData[2];
moviesDirector = RowData[3];
db.execSQL("insert into movies(_id, title, year, director) values(" + moviesID + ", '" + moviesTitle + "', " + moviesYear + ", '" + moviesDirector + "');");
}
} catch (IOException e) {
e.printStackTrace();
}