How can we push ".db" to the emulator?

Can we create a database created by some idea like sqlitestudio and paste it into our emulator for using applications ? is there any way to push our ".db" format into the andriod emulator?

+5
source share
5 answers

I think you want to send you an application by creating a database from the outside, this is a good tutorial for adding a database to your application, and these are some good tutorials to start with

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

http://mfarhan133.wordpress.com/2010/10/24/database-crud-tutorial-for-android/

http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/

+3

, USB, :

adb push c:\local_path\myfile.db /path_on_the_device/myfile
+3

db sd .

private void CopyFileFromAssets() {
    AssetManager asm = getAssets();
    String[] files = null;
    try {
        files = asm.list("");
    } catch (IOException e) {
        Log.e("tag", e.getMessage());
    }
    for(String filename : files) {
        InputStream in = null;
        OutputStream out = null;
        try {
          in = asm.open(filename);
          //you can even create folder to put your file
          out = new FileOutputStream("/sdcard/" + filename);
          copyFile(in, out);
          in.close();
          in = null;
          out.flush();
          out.close();
          out = null;
        } catch(Exception e) {
            Log.e("tag", e.getMessage());
        }       
    }
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
    byte[] buffer = new byte[1024];
    int read;
    while((read = in.read(buffer)) != -1){
      out.write(buffer, 0, read);
    }
}

,

+2

explorer - data - data - pkg - .

0

db.

1. DDMS

2. then select the emulator from the device tab

3. go to data / data // databases

4. Now click on the file in the emulator using in the upper right corner of the window.

5. Now run the application.

Thank.

0
source

All Articles