1

I create a table in sqlite database I am doing all the CRUD operation but I want to see my database schema . I try through DDMS tool of eclipse IDE but there is no database. How can I see my database.i am using real device. Please Help me. Thanks in advance

Mss iOS
  • 157
  • 9

3 Answers3

1

You can use this method:

STEP 1: First export the database by writing function :

public static void backupDatabase() throws IOException {
    //Open your local db as the input stream
    String inFileName = "/data/data/com.myapp.main/databases/MYDB";
    File dbFile = new File(inFileName);
    FileInputStream fis = new FileInputStream(dbFile);

    String outFileName = Environment.getExternalStorageDirectory()+"/MYDB";
    //Open the empty db as the output stream
    OutputStream output = new FileOutputStream(outFileName);
    //transfer bytes from the inputfile to the outputfile
    byte[] buffer = new byte[1024];
    int length;
    while ((length = fis.read(buffer))>0){
        output.write(buffer, 0, length);
    }
    //Close the streams
    output.flush();
    output.close();
    fis.close();
}

Taken from Stack overflow link

Then download DB Browser for SQLite and open database file there.DB Browser for SQLite

And you are good to go.Inform me if you found any difficulties while implementing this.

Community
  • 1
  • 1
Smit.Satodia
  • 597
  • 4
  • 13
0

In a real device you cannot access the SQLite DB unless ur phone is rooted.. in a virtual device however you can access it. but there is no way u can see the actual schema. all you see is some text files and once you open them up your columns(data fields) are separated by tabs or something. so

How can I see my database? YOU CAN'T

Infamous
  • 744
  • 11
  • 25
0

Only rooted real device can be access using some jar in eclipse. Other wise you can seed database structure in emulator from DDMS Respective. To know how to do this. Please red this to solve your problem.

Community
  • 1
  • 1