Ubicación de la base de datos en android

In my application i have one database,i want to view that database,i followed the following steps:

data > data > your-package-name >(After this it shows two folders,i cant see anyoption for database) databases > your-database-file.

But i cant see the database file.It shows two folders inside my package.Anybody please help me.

preguntado el 04 de julio de 12 a las 05:07

2 Respuestas

Then following this path, you should see two file without extension. but you can not see content of DB.

If you wanna see it, you should push then import an other SQLite Manager(such as Firefox add-on). Maybe you don't be able to create database, If you can't see it.


Actualizar: For Insert, Delete or get DB in Emulator, you should install Android DDMS(in Eclips help menu->install software) and select in order Empuje, Borrar y Jale iconos.

enter image description here

Respondido 04 Jul 12, 07:07

hi omid nazifi thanks ..Now i don't want to see the database,now i want to delete the database.. - Subbu

@subbu: Do you wanna delete DB in app or delete as manual inner emulator? - omid nazifi

I want to delete the database in emulator.Y because i am inserting new feild into table,But it is not overwritting the previous.SO if i delete and try means it will work i think so.. - Subbu

Yes, You just select DB and click on delete icon. I'll put an image for you. - omid nazifi

You cannot access files on your device in the data directory unless you have rooted your phone (it's a security precaution).

Tienes algunas opciones:

1) Run your app in the emulator and pull the database form there using the DDMS

2) Root your phone

3) Put a method in your app to copy your database to a place that you can access outside of the app (such as your SD card).

Simple code to copy to the SD card:

public void backup() {
    try {
        File sdcard = Environment.getExternalStorageDirectory();
        File outputFile = new File(sdcard,
                "yourdb.sqlite");

        if (!outputFile.exists()) 
             outputFile.createNewFile(); 

        File data = Environment.getDataDirectory();
        File inputFile = new File(data,
                "data/your.package.name/databases/yourdb.sqlite");
        InputStream input = new FileInputStream(inputFile);
        OutputStream output = new FileOutputStream(outputFile);
        byte[] buffer = new byte[1024];
        int length;
        while ((length = input.read(buffer)) > 0) {
            output.write(buffer, 0, length);
        }
        output.flush();
        output.close();
        input.close();
    } catch (IOException e) {
        e.printStackTrace();
        throw new Error("Copying Failed");
    }
}

Respondido 04 Jul 12, 05:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.