본문 바로가기
호기심_메모

[sqlite3] adb로 db 보기

by 겸손하게 빚진자로, 밝게 인사 2021. 8. 13.
728x90

// 사용 사례

 

C:\adb shell

 

#cd /data/dbdata/databases/com.android.providers.contacts

 

#sqlite3 contacts2.db

 

sqlite>.tables

 

sqlite>select * from contacts;

 

// 개발자 사이트 설명

sqlite3

From a remote shell to your device or from your host machine, you can use the sqlite3 command-line program to manage SQLite databases created by Android applications. The sqlite3 tool includes many useful commands, such as .dump to print out the contents of a table and .schema to print the SQL CREATE statement for an existing table. The tool also gives you the ability to execute SQLite commands on the fly.

To use sqlite3 from a remote shell:

  1. Enter a remote shell by entering the following command:adb [-d|-e|-s {<serialNumber>}] shell
  2. From a remote shell, start the sqlite3 tool by entering the following command:sqlite3You can also optionally specify a full path to a database that you want to explore. Emulator/device instances store SQLite3 databases in the directory /data/data/<package_name>/databases/.
  3. Once you invoke sqlite3, you can issue sqlite3 commands in the shell. To exit and return to the adb remote shell, enter exit or press CTRL+D.

Here's an example:

$ adb -s emulator-5554 shell 
# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db 
SQLite version 3.3.12 
Enter ".help" for instructions 
.... enter commands, then quit... 
# sqlite> .exit

To use sqlite3 locally, instead of within a shell, pull the database file from the device and start sqlite3:

  1. Copy a database file from your device to your host machine:adb pull <database-file-on-device>
  2. Start the sqlite3 tool from the /tools directory, specifying the database file:sqlite3 <database-file-on-host>

 

<참고>

http://www.dreamy.pe.kr/zbxe/index.php?mid=CodeClip&category=113507&page=2&document_srl=157109

 

sqlite 다운로드 : http://www.sqlite.org/

Command line shell for SQLite : http://www.sqlite.org/sqlite.html

반응형

'호기심_메모' 카테고리의 다른 글

[환경세팅] Android 앱 진단  (0) 2021.08.13
getprop 명령어  (0) 2021.08.13
[원격 ADB] 여러대의 스마트폰에 쉽게 접속하기  (1) 2021.08.13
우분투에 오라클 설치하기  (0) 2021.08.13
무선랜 보안점검  (0) 2021.08.13