Android
2016.03.28 20:31

adb shell 에서 sqilte3 사용 하기

조회 수 13541 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print

디버깅 중, DB 파일을 다뤄야 할 때가 많습니다.

유용한 PC 툴이 많이 있지만, 안드로이드의 adb 에서도 sqlite3 를 지원하고 있습니다.

해당 기능을 이용하면, DB 파일을 간단히 확인해야 할 때 특히 유용합니다.(따로 PC툴을 열거나 DB파일을 PC로 옮길 필요가 없음)

아래 예제를 보면서 사용하는 방법을 익혀보세요. 4,5번을 보시면 아시겠지만 일반 SQL 문이 그대로 적용됩니다.

1.  DB 파일로 접근하기

-> adb shell # sqlite3 <DB 파일 경로>

------------------------------------------------------------------------------------------------------------------------------

2|shell@android:/ # sqlite3 /data/data/com.lge.qremote/databases/qremotesettings.db
emote/databases/qremotesettings.db <
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

 

2. 기본 명령어 확인하기

sqlite> .help


3. 해당 DB의 table 확인하기

 

sqlite> .tables
.tables
android_metadata tblDevices tblRooms
tblBrandNames tblFavoriteChannels tblWiFiRemoteTvInfo
tblCustomRemoteInfo tblPreferences


4. 해당 table 내용 읽기

.headers on 을 미리 입력하면, table의 header 정보를 함께 보여줍니다.

------------------------------------------------------------------------------------------------------------------------------

 

sqlite> .headers on
.headers on
sqlite> select * from tblRooms;
select * from tblRooms;
room_id|room_name|icon|current_room
1|living_room|0|1
2|bed_room|6|0
3|sp_Kitchen_NORMAL|12|0
4|sp_Den_room_NORMAL|18|0
5|office|24|0

 

5. DB 수정하기

sqlite> update tblRooms set current_room=5 where room_id=4;
update tblRooms set current_room=5 where room_id=4;
sqlite> select * from tblRooms;
select * from tblRooms;
room_id|room_name|icon|current_room
1|living_room|0|1
2|bed_room|6|0
3|sp_Kitchen_NORMAL|12|0
4|sp_Den_room_NORMAL|18|5
5|office|24|0
sqlite>


Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
431 Pi 라즈베리파이 커널 컴파일 2017.10.18 6616 0
430 Android Git 특정 commit 상태로 되돌리고 SHA1 값 알아내기 2015.05.13 6620 0
429 C# How to: Programmatically Add an Entry to Outlook Contacts 2015.05.27 6624 0
428 Python matplot에서 한글이 보이도록 하는 코드 2019.03.06 6669 0
427 업무 ABS / PLA 2017.01.18 6698 0
426 Pi 라즈베리파이 gpio utility 2017.02.15 6759 0
425 Pi LCD interface 종류 및 Driver IC 2017.04.17 6844 0
424 일반 DivX 기술 간단 개요 2014.07.08 6910 0
423 Pi 라즈베리파이 음성인식 S/W 2018.04.26 6913 0
422 Pi 안면인식, 동작인식을위한 OpenCV 설치 및 샘플 2017.10.18 7017 0
421 Android Fake Incoming Call Android 2015.07.23 7095 0
420 LINUX 리눅스의 기본 명령어들 2015.01.20 7109 0
419 C# Best way to implement keyboard shortcuts in a Windows Forms application 2015.11.06 7128 0
418 MFC [Collection] ArrayList 예제 2017.01.25 7152 0
417 일반 BT와 BLE 2017.05.16 7153 0
목록
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5