Can we push a database that is created by some ide like sqlitestudio and push it into our emulator for app uses? is there any way to push our ".db" format into andriod emulator?
5 Answers
I think you want to ship you application by creating database outside , these are good tutorial to add database to your application , and these are few 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/

- 4,403
- 8
- 36
- 67
If your device is an emulator or is a physical device connected thru USB, you can use this command-line:
adb push c:\local_path\myfile.db /path_on_the_device/myfile

- 10,917
- 4
- 51
- 70
-
is path_on_th_device same for all devices? Can you please give an practical example? – Shirish Herwade Jan 10 '18 at 13:54
-
@ShirishHerwade No, the path depends on where you would like to push the file. And example is `adb push c:\tmp\file.txt /sdcard/tmp/file.txt`. I usually use that with emulators (which are rooted) or with my phone but it is rooted. You can have a look at this for further details: https://stackoverflow.com/questions/20834241/how-to-use-adb-command-to-push-a-file-on-device-without-sd-card – Shlublu Jan 10 '18 at 14:36
You better add db into assets and copy it into sd or internal storage. Here is some code snippet for you
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);
}
}
Hope this can help
-
true, but it's better to push it directly in the app database folder - "/data/data/[rootpackage]/databases/" – mihail Aug 30 '11 at 11:33
Go to file explorer - data - data - your pkg name - select database and click on push a file onto the device.

- 917
- 1
- 6
- 16
First remove the db extension.
1.then select DDMS
2.then select emulator from device tab
3.move to data/data//databases
4.now push file into emulator using the top-right open in window.
5.Now run the app.
Thank you.

- 3,265
- 9
- 48
- 72