Android
2016.03.28 20:31

adb shell 에서 sqilte3 사용 하기

조회 수 13123 댓글 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
번호 분류 제목 날짜 조회 수 추천 수
401 Android Wifi을 이용한 adb 연결 2012.02.28 20975 0
400 LINUX 간단 UNIX / LINUX 명령어 정리 2012.02.28 17228 0
399 개념 UDS (Unix Domain Socket) 2012.02.28 32325 0
398 일반 CSS 참고 사이트 2012.06.05 15497 0
397 개념 SEI(Supplemental Enhancement Information) - H.264, AVC 2012.03.29 18315 0
396 개념 CMLA (Content Management Licensing Administrator) DRM 2012.03.30 15573 0
395 C# 문자열 다루기 1 2012.04.06 18692 0
394 C# C# 형변환 (문자형 -> 숫자형) / C# Type Change (string -> number) 2012.04.12 57450 0
393 Android logcat 사용법 2012.04.12 36260 0
392 LINUX zip 명령어 사용법 1 2012.04.16 28700 0
391 C# C# ?? 및 ??=, ?. 연산자 2021.05.09 3267 0
390 Android [GIT 사용법] Dreamy의 요약 2 secret 2012.04.20 158 0
389 LINUX KScope 사용법 2012.04.23 15249 0
388 개념 CSFB와 SVLTE (Circuit Switched Fall-Back & Simultaneous Voice and LTE) 2012.04.23 24426 0
387 Android Git 사용자 설명서 2012.04.24 16141 0
목록
Board Pagination ‹ Prev 1 ... 3 4 5 6 7 8 9 10 11 12 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


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

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

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5