네트워킹

오늘:
1,108
어제:
2,375
전체:
2,786,844

고객센타 : 070-7752-2000
팩스 : 070-7752-2001
휴대폰 : 010-9513-0019
email : voipkorea@yahoo.co.kr

국민은행
(주)제이에스솔루션
047101-04-155519

Flag Counter
■ 무료 : 유선 집전화 휴대폰 ( 한국 미국 중국 카나다) ↔ (국내 해외 여행자 상사 주재원 유학생) / 가입무 무제한무료■

http://www.techrepublic.com/blog/software-engineer/browse-sqlite-data-on-the-android-emulator/



This demo shows how developer William J. Francis often debugs SQLite tables through the Android emulator. 

While Android puts a powerful built-in database at your disposal, it doesn't come with the best set of debugging tools. In fact, unless you have a rooted device, you can't even get the SQLitetables off your device without jumping through some hoops.  Fortunately, the Android emulatordoesn't have this restriction.

This walk-thru demonstrates how I generally debug SQLite tables. If you aren't familiar with SQLite tables on Android, read my TechRepublic article, "Use SQLite to create a contacts browser in Android."

1. This tutorial doesn't cover CRUD operations for SQLite; however, we do need data to debug in order to demonstrate the technique. I used the short code snippet below to create a sample database.

package com.authorwjf.sqlitetablemaker;
import android.os.Bundle;import android.widget.Toast;
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;


public class MainActivity extends Activity {

	private static final String SAMPLE_DB_NAME = "TrekBook";
	private static final String SAMPLE_TABLE_NAME = "Info";
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SQLiteDatabase sampleDB =  this.openOrCreateDatabase(SAMPLE_DB_NAME, MODE_PRIVATE, null);
		sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " +
                SAMPLE_TABLE_NAME +
                " (LastName VARCHAR, FirstName VARCHAR," +
                " Rank VARCHAR);");
        sampleDB.execSQL("INSERT INTO " +
                SAMPLE_TABLE_NAME +
                " Values ('Kirk','James, T','Captain');");
        sampleDB.close();
        Toast.makeText(this, "DB Created!", Toast.LENGTH_LONG).show();
    }

   
}


2. The second step is to open an emulator that contains the table you want to browse. In this instance using Eclipse, I opened a new emulator and loaded the sqlitetablemaker.apk on it (Figure A).

Figure A

create_db_01_072413.png

3. Within Eclipse, you need to switch to DDMS mode by going to Window | Open Perspective | DDMS. If you've never used DDMS, you'll likely need to go to Window | Open Perspective | Other and then browse for DDMS within the list (Figures B and C).

Figure B

create_db_02_072413.png

Figure C

create_db_03_072413.png

4. Once the DDMS view is active, choose the File Explorer tab. You'll find your database in the /data/data/your.app.namespace/databases directory. There are two virtually indistinguishable icons in the upper right-hand corner of the tab that represent a pull and a push of a file, respectively. Use the pull icon (the one on the left) to save a copy of the SQLite database to your development machine (Figure D).

Figure D

create_db_04_072413.png

5. Now you have a copy of your database on your workstation, but you still need some kind of SQLite viewer to take a peek. I use SQLite Database Browser, because it is free and runs on my Wintel, Mac, and Ubuntu boxes. 

6. Open the database and inspect the data (Figure E).

Figure E

create_db_05_072413.png

While it's not terribly difficult to get a look at the SQLite tables you create in your Android apps, it requires quite a few steps. And remember this only works with the emulator -- if you need to debug SQLite tables on an actual device, you’ll need to create an export function that copies the database to the SD card, at which point you can follow this walk-thru to open the tables.

I hope future versions of the Android development tools will make this process less painful. Until then, you may want to save this article!

About 

William J Francis began programming computers at age eleven. Specializing in embedded and mobile platforms, he has more than 20 years of professional software engineering under his belt, including a four year stint in the US Army's Military Intellige...

조회 수 :
10826
등록일 :
2014.02.15
14:04:53 (*.251.139.148)
엮인글 :
http://webs.co.kr/index.php?document_srl=38771&act=trackback&key=4d9
게시글 주소 :
http://webs.co.kr/index.php?document_srl=38771
List of Articles
번호 제목 글쓴이 날짜 조회 수
55 Sqlite very detail easy tutorial I recommand this admin 2017-09-09 422
54 mysql 로컬접속 풀고 특정 아이피 접속 허가 허락 가능 하게 설정 하는 방법 admin 2017-09-05 423
53 linux command chmod 리눅스 명령어 가장 쉽게 이해하기 설명 사용자 구룹 타인 권한 admin 2017-09-05 431
52 mariadb CREATE USER CREATE USER statement creates new MariaDB accounts. admin 2017-09-01 434
51 MySQL 데이터 베이스 백업 및 복구 방법 admin 2017-09-01 452
50 Allowing MySQL Root Login from All IP Addresses : admin 2017-08-17 391
49 Installation of MySQL Database Server admin 2017-08-17 417
48 mysql 쿼리 로그 남기기 (실시간) admin 2015-04-15 3378
47 SQL Delete records using subqueries admin 2015-04-03 3366
46 Mysql privilege table GRANT SELECT,INSERT,UPDATE,DELETE ON db.table admin 2015-04-02 3551
45 안드로이드 SQLite 속도 향상! insert Transaction admin 2014-04-07 13773
44 MySQL에 원격 접속 허용 여러가지 아이피 아이피대역으로 admin 2014-04-02 10839
43 10gR2_sles10_install file admin 2014-03-18 8838
42 this is final answer assets sqlite Databases trouble copy External DB, check eclips admin 2014-02-18 9291
» Browse SQLite data on the Android emulator admin 2014-02-15 10826
40 SQLite Database Browser file admin 2014-02-14 9670
39 SQLite Databases using External DB admin 2014-02-14 13811
38 sqlite DB copy admin 2014-02-14 9617
37 Android SQLite Database with Multiple Tables admin 2014-02-13 9113
36 Android Simple Clean Good SQLite Database Tutorial 잘된 설명 admin 2014-02-13 9820
35 android sqlite 사용하기 admin 2014-02-10 13869
34 SQLite 개발가이드 데이터베이스의 성능 admin 2014-02-10 15545
33 android - 다수의 Insert 수행시 속도 향상을 위한 팁 sQlite admin 2014-02-10 10363
32 Oracle Linux 에 Oracle DB 설치하기 admin 2013-12-03 13335
31 PreparedStatement mysql java 깔끔한설명 admin 2013-10-26 16367
30 Connect Excel VBA to a MySQL database file admin 2013-09-05 12380
29 Configuring Oracle ASM disks in Oracle Enterprise Linux admin 2013-04-20 10741
28 OS에따른 Oracle 설치버전 admin 2013-04-08 11847
27 RHEL4 + 10g 설치 _silent mode admin 2013-04-08 11733
26 OLE5 + 11G 설치 _silent mode admin 2013-04-08 14890
25 WHERE 조건절 검색시 서브쿼리는 어떻게? admin 2013-04-01 11420
24 CDR 추출 저장 Inner Join 사용 Sql 문 admin 2013-02-05 11730
23 SUPER OCM 1.8club admin 2012-12-18 11123
22 MySQL Java tutorial admin 2012-09-30 16185
21 Oracle 10g Articles admin 2012-06-24 12892
20 기본 10g 설치의 리눅스 세팅에서 추가 해줘야하는 사항(윈도우) admin 2012-06-24 13988
19 SUSE Linux Enterprise Server 10 (Oracle 10g R2 (10.2.0.1)) file admin 2012-03-09 12906
18 Upgrade Oracle from 10.2.0.1 To 10.2.0.4 (Windows) admin 2012-03-06 18011
17 Upgrade Oracle 10g Release 2 from 10201 to 10204 admin 2012-03-05 25493
16 centos 6.2 oracle 10g 설치 admin 2012-03-05 28502
15 Oracle RHEL4+10G 10.2.0.1 설치 10.2.0.5 패치 admin 2012-03-03 17863
14 Oracle Backup & restore with RMAN 기본 admin 2012-02-12 13148
13 오라클 ACE가 해설하는 Oracle Backup & Recovery admin 2012-02-07 13028
12 Oracle Backup & Restore admin 2012-02-07 17436
11 http://www.hoons.kr/ admin 2011-12-19 13090
10 Java && Excel 연동 JAVA 자바로 엑셀을 핸들링 할 수 있는 방법 admin 2011-12-19 32929
9 (C#) ASP.NET MySQL Check Already Exists Add/Insert Record 프로그래밍 코드 admin 2011-12-19 13378
8 xhost and display admin 2011-12-16 12260
7 Oracle 설치 Centos ,openSUSE,엔터프라이즈등 퍼온글 admin 2011-12-16 14181
6 Oracle 의 ASM 구조 알아보기.. admin 2011-12-16 17650