Сохранение данных из XML в SQLite Android

Используем xml файл из res/xml/animals_records.xml

<?xml version="1.0" encoding="utf-8"?>
<animals>
    <record title="Dog" color="Brown" />
    <record title="Cat" color="Gray" />
    <record title="Rabbit" color="White" />
    <record title="Spider" color="Black" />
</animals>

Создание базы данных БД
Используем SQLiteOpenHelper для создания и обновления таблиц в БД.

/**
* This class helps open, create, and upgrade the database file.
*/
private static class DatabaseHelper extends SQLiteOpenHelper {
    
    private final Context fContext;
    
    DatabaseHelper(Context context) {
        super(context, "sampledb", null, 1);
        fContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE animals ("
                + "_id INTEGER PRIMARY KEY,"
                + "title TEXT,"
                + "color TEXT"
                + ");");

        //Add default records to animals
        ContentValues _Values = new ContentValues();                          
        //Get xml resource file
        Resources res = fContext.getResources();
        
        //Open xml file
        XmlResourceParser _xml = res.getXml(R.xml.animals_records);
        try
        {
            //Check for end of document
            int eventType = _xml.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                //Search for record tags
                if ((eventType == XmlPullParser.START_TAG) &&(_xml.getName().equals("record"))){
                    //Record tag found, now get values and insert record
                    String _Title = _xml.getAttributeValue(null, AnimalColumns.TITLE);
                    String _Color = _xml.getAttributeValue(null, AnimalColumns.COLOR, 0);
                    _Values.put(AnimalColumns.TITLE, _Title);
                    _Values.put(AnimalColumns.COLOR, _Color);
                    db.insert(AnimalColumns.TABLENAME, null, _Values);            
                }
                eventType = _xml.next();
            }
        }
        //Catch errors
        catch (XmlPullParserException e)
        {     
            Log.e(TAG, e.getMessage(), e);
        }
        catch (IOException e)
        {
            Log.e(TAG, e.getMessage(), e);
            
        }         
        finally
        {         
            //Close the xml file
            _xml.close();
        }
    }

    /* Update database to latest version */
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //Crude update, make sure to implement a correct one when needed.
                    
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS animals");
        onCreate(db);
    }
}

Код примера взят отсюда http://martin.cubeactive.com/android-filling-a-table-from-resource-file-...