Can you really have a csv file saved within the res/raw resource directory and employ it to populate a table within the sqlite3 database?

My thought was that, if there is a method to perform a bulk import for the whole file in to the table then that might be cleaner and faster than iterating over each line within the file and performing individual place claims...

I have discovered that there's a sqlite import command that enables this:

...but I am getting trouble using individuals claims during my Android application. My first thought ended up being to try something similar to the next...but no luck:

db.execSQL(".mode csv");
db.execSQL(".import res/raw/MyFile.csv " + TABLE_NAME); 

Is possible?

Must I be trying another method of populate my database?

UPDATE: I am marking Josef's response because the answer (bulk place using transactions) since it works fine and directly solutions my question according to my title (thanks Josef). However, I am am still searching for a method to perform a bulk place within an Android application from csv file right into a sqlite3 table while using import statement. Knowing how to get this done please respond.

Thank you for you solutions!

If you wish to package static data together with your application, I suggest planning the database at development time (using any UI or csv-import command you want) and shipping the sqlite file within the assets folder. After that you can simply copy the whole sqlite file to the device whenever your application is first run. These posts guide you through this concept which is the quickest method to setup a database (file copy speed).

If, for whatever reason you need to place lots of data at run time, I suggest you take a look at methods to bulk place using transactions to hurry up.

I spent a lot of time searching for an easy solution and emerged with this particular bit of code myself. For future people searching for this like I had been this can be used:

            BufferedReader in = new BufferedReader(your csv flie source here);
        String reader = "";
        while ((reader = in.readLine()) != null){
            String[] RowData = reader.split(",");
            date = RowData[0];
            value = RowData[1];
            ContentValues values = new ContentValues();
            values.put(CsvProvider.DATE, date);
            values.put(CsvProvider.VALUE, value);
            getContentResolver().insert(CsvProvider.CONTENT_URI, values);

My CSV file doesn't have game titles and just has 2 column but a lot more than two posts should not be any problem. Just be sure you specify what's splitting your posts as well as for each column add another RowData[#](you need to begin with ). You need to make certain whatever you're going related to each lines are done before you decide to get in touch with.near(). I'm utilizing a content provider however, you can definitely do anything you want using the data like append it to some String[] or other things.

As I am utilizing an input stream you are able to point the BufferedReader to wherever you would like. As lengthy because the BufferedReader can see after that it it'll work.