I'm focusing on an Android application which will need several records (just one table, with 1000-10000 rows) populated for the reason that app's database prior to the user may use that application. I have looked around some lessons and i'm unclear about the easiest method to do that. Must I just see if the database is available every time the application is began and, whether it is not there, create it and place the 1000's of records I want? Or it is possible to better way additional problem? Ideally, it may be incorporated included in the app's install process, but I am unsure if this sounds like possible. Any feedback could be greatly appreciated.

the way in which I am visiting this site would be to ship a prepopulated database within the assets folder. You are able to stop by files there and employ them as-they-are. Beware, however, that there's a size limit ( I suppose it had been 1 or 5 Megabytes ), so perhaps you will need to split files, or compress them.

Compression is very handy and well based on the os itself.

hope it was associated with a help :-)

JavaDoc from SQLiteOpenHelper:

A assistant class to handle database creation and version management. You produce a subclass applying onCreate(SQLiteDatabase), onUpgrade(SQLiteDatabase, int, int) and optionally onOpen(SQLiteDatabase), which class takes proper care of opening the database whether it is available, creating it if it doesn't, and improving it as being necessary. Transactions are utilized to make certain the database is definitely inside a sensible condition.

To have an example, begin to see the NotePadProvider class within the NotePad sample application, within the samples/ directory from the SDK.

If you extend these kinds, you've 3 techniques which is contacted certain cases and you will choose, exactly what do to. Thats the very best practice :)

Here's a good example of how you can create and populate a database, you can easily do that around the application install, this only produces one entry though so might be inefficient for which for you to do.

private static class settingsDatabaseHelper extends SQLiteOpenHelper{

    //SQL String for creating the table required
    private static final String CREATE_SETTINGS_TABLE
    = "CREATE TABLE tbl_settings(" +
            "VOIPUSERNAME TEXT," +
            "VOIPAUTHID TEXT," +
            "PASSWORD TEXT," +
            "SIPPROXYSERVER TEXT," +
            "SIPREGISTRAR TEXT," +
            "SIPREALM TEXT," +
            "EXPIRESTIME INTEGER);";    

    public settingsDatabaseHelper(Context context, String name,
            CursorFactory factory, int version) {
        super(context, name, factory, version);


    public void onCreate(SQLiteDatabase db) {
         ContentValues initialValues = new ContentValues();
            initialValues.put("VOIPUSERNAME", "xxxxx");
            initialValues.put("VOIPAUTHID", "xxxxxxxxxx");
            initialValues.put("PASSWORD", "xxxxxx");
            initialValues.put("VOIPDISPLAYNAME", "xxxxxxxxx");
            initialValues.put("SIPPROXYSERVER", "xxxxxxxxxxxxx");
            initialValues.put("SIPREGISTRAR", "xxxxxxxxxxx");
            initialValues.put("SIPREALM", "xxxxxxxxxx");
            initialValues.put("EXPIRESTIME", xxxxxxxxxxx);
            Log.d("1.6", "gets to here");
            db.insert(SETTINGS_TABLE, null, initialValues);


    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to " +
                 newVersion + ", which will destroy all old data");




//end helper class