I'm trying to populate a database when install the app, but my method read
only the first line of table, anyone knows a best method to populate the
database with sql statement at first app run.


    private static class ChordDbHelper extends SQLiteOpenHelper
    {
        private String fileString;
        public ChordDbHelper(Context context, String name,CursorFactory
factory, int version)
        {
            super(context, name, factory, version);
            try {
                InputStream is =
context.getResources().openRawResource(R.raw.chord_database);
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader in = new BufferedReader(isr);
                fileString = in.readLine();
                in.readLine();
                in.close();

            }catch (IOException e) {
                Log.println(Log.DEBUG,"chord_database",e.getMessage());
            }
        }

        @Override
        public void onCreate(SQLiteDatabase db)
        {
            Log.println(Log.DEBUG,"chord_database","trying read to db");
            db.execSQL(fileString);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion)
        {
            db.execSQL("DROP TABLE IF EXISTS " +  CHORD_TABLE);
            onCreate(db);
        }
    }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to