한국어

네트워킹

온누리070 플레이스토어 다운로드
    acrobits softphone
     온누리 070 카카오 프러스 친구추가온누리 070 카카오 프러스 친구추가친추
     카카오톡 채팅 상담 카카오톡 채팅 상담카톡
    
     라인상담
     라인으로 공유

     페북공유

   ◎위챗 : speedseoul


  
     PAYPAL
     
     PRICE
     

pixel.gif

    before pay call 0088 from app


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...

조회 수 :
34955
등록일 :
2014.02.15
14:04:53 (*.251.139.148)
엮인글 :
http://webs.co.kr/index.php?document_srl=38771&act=trackback&key=ac5
게시글 주소 :
http://webs.co.kr/index.php?document_srl=38771
List of Articles
번호 제목 글쓴이 조회 수sort 추천 수 날짜
37 Oracle 설치 Centos ,openSUSE,엔터프라이즈등 퍼온글 admin 36364   2011-12-16
 
36 오라클 아키텍쳐 admin 35957   2011-12-13
 
35 SQLite Databases using External DB admin 35952   2014-02-14
 
» Browse SQLite data on the Android emulator admin 34955   2014-02-15
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...  
33 xhost and display admin 34587   2011-12-16
 
32 http://www.hoons.kr/ admin 34518   2011-12-19
 
31 (C#) ASP.NET MySQL Check Already Exists Add/Insert Record 프로그래밍 코드 admin 34353   2011-12-19
 
30 Android Simple Clean Good SQLite Database Tutorial 잘된 설명 admin 33935   2014-02-13
 
29 Oracle Preinstallation Tasks admin 33211   2011-12-16
 
28 sqlite DB copy admin 33101   2014-02-14
 
27 SQLite Database Browser file admin 32560   2014-02-14
 
26 Allowing MySQL Root Login from All IP Addresses : admin 31872   2017-08-17
 
25 OS에따른 Oracle 설치버전 admin 31740   2013-04-08
 
24 Oracle 10g Articles admin 31735   2012-06-24
 
23 SUPER OCM 1.8club admin 30764   2012-12-18
 
22 this is final answer assets sqlite Databases trouble copy External DB, check eclips admin 29624   2014-02-18
 
21 10gR2_sles10_install file admin 25962   2014-03-18
 
20 두테이블비교 한쪽에 없는 값 추출 mysql left right outer join 서브쿼리 값사용 admin 25944   2019-07-10
 
19 원격 IP로 MySQL(MariaDB)에 접속 방법 해법 설정 순서 admin 24958   2019-06-19
 
18 mysql 쿼리 로그 남기기 (실시간) admin 24319   2015-04-15
 
17 SQL Delete records using subqueries admin 23768   2015-04-03
 
16 Mysql privilege table GRANT SELECT,INSERT,UPDATE,DELETE ON db.table admin 21542   2015-04-02
 
15 linux command chmod 리눅스 명령어 가장 쉽게 이해하기 설명 사용자 구룹 타인 권한 admin 20617   2017-09-05
 
14 MySQL 데이터 베이스 백업 및 복구 방법 admin 20326   2017-09-01
 
13 mysql 로컬접속 풀고 특정 아이피 접속 허가 허락 가능 하게 설정 하는 방법 admin 20178   2017-09-05
 
12 Sqlite very detail easy tutorial I recommand this admin 19032   2017-09-09
 
11 숫자 날짜 문자열 문자 공간 JSON MySQL 자료형 총 정리 phpMyAdmin 자료형 admin 18622   2018-03-26
 
10 Installation of MySQL Database Server admin 18168   2017-08-17
 
9 oracle download install 오라클 다운로드 설치 admin 16905   2018-05-29
 
8 [SQL] 테이블 안의 컬럼 값 변경, 수정, UPDATE admin 16792   2019-10-21