Java tutorial
//package com.java2s; import android.content.Context; import android.content.ContextWrapper; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void setupDatabase(Context context, String db_name) { ContextWrapper cw = new ContextWrapper(context); String db_path = cw.getDatabasePath(db_name).getPath(); try { // Setup byte[] buffer = new byte[1024]; int length; InputStream myInput = context.getAssets().open(db_name); OutputStream myOutput = new FileOutputStream(db_path); // Write all the things. while ((length = myInput.read(buffer)) > 0) myOutput.write(buffer, 0, length); // Cleanup myOutput.close(); myOutput.flush(); myInput.close(); } catch (IOException e) { // You done goofed. e.printStackTrace(); } } }