I've produced a SQLite file and putted it onto assets folder. Now I can browse the data from that file however i haven't any idea crafting for this database file. I have to go ahead and take user title and score and store that directly into that database file. I looked web around the SO also but you will find good examples for that normal database insertion.

Can anyone let me know how you can keep values into database file. I have to keep username and score. Imagine this to as Strings and please produce a example for this.

Because the /asset directory is read only (because android .apk file is read-only) which means you can't write anything in resource folder file, you need to first copy that sqlite database file to your application's internal storage /data/data/<package_name>/databases directory you'll be able to modify your database file..

  1. Copy your pre-populated sqlite database file into data/data/<package_name>/databases directory,

  2. Open that database file (from /databases/ directory) inside your sqlite database assistant class..

  3. Perform place, update or choose operation on that database..

you have to copy database file from resource and paste in /data/data/''/databases/ folder

private static String DB_NAME = "QuotesData.db";
private static String DB_PATH = "/data/data/[PACKAGE NAME]/databases/";
private void copyDataBase() throws IOException {

        InputStream myInput = context.getAssets().open(DB_NAME);

        String outFileName = DB_PATH + DB_NAME;

        OutputStream myOutput = new FileOutputStream(outFileName);

        byte[] buffer = new byte[1024];
        int length;
        while ((length = myInput.read(buffer)) > 0) {
            myOutput.write(buffer, 0, length);
        }

        myOutput.flush();
        myOutput.close();
        myInput.close();

    }

In Above code : Replace [PACKAGE Title ] together with your package title I really hope above code can help.

Thanks