开发者

how to delete all the contents of a table and how to see the database in Eclipse or in Android Emulator

I made a database in android Application name MgilePPR

in which I created a table named Provider(s_no,id,description)

Table has created successfully and 4 rows are inserted in it

but every time i run my application it increases the row by +4

so I have two questions

  1. How do i empty a table before ins开发者_C百科erting records?
  2. How do i see my database and table content in Eclipse or in Android emulator?

thanks for the replys in advance


  1. How to remove everything: execute SQL command DELETE FROM Provider.

  2. How to view your database contents: this is described in developer's guide - Examining databases from a remote shell. Basically you open command line, type adb shell, then enter command like sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db (substitute com.example.google.rss.rssexample with your application package). Then you can enter commands for sqlite. If you want to look at the contents of your database, just enter .dump.

One thing I've noticed: on emulator two files are actually created in databases folder, one is with extension .db and the other one without anything. So if you open db file and it contains nothing, try opening the other one.


hello I Think are writing code in onCreate() method and this will call each and every time as you run the activity.

You have to make a separate Function for that and you have to call when you want to insert data

and you want to see the contents of the table so open DDMS=>File Explorer=>data=>data=>package name of your application=>databases

now on right side there is option for push the file to your computer so save the file to your computer

now if you are using Mozilla then install Add-ons for SQLite manager or you can download sqlite query browser

then open your database file into that software

you can then access that database


go to terminal and do like this

cd <platforms tools>
./adb shell
cd data
cd data

now you want to see your packages type ls

you can able to see your workspace packages

now type cd <your package name> then

cd databases
sqlite3 <your database name>

now your can enter the sqlite database. you want to see your tables use .tables

note:your emulator should be on running mode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜