한국어

네트워킹

온누리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...

조회 수 :
34987
등록일 :
2014.02.15
14:04:53 (*.251.139.148)
엮인글 :
http://webs.co.kr/index.php?document_srl=38771&act=trackback&key=781
게시글 주소 :
http://webs.co.kr/index.php?document_srl=38771
List of Articles
번호 제목 글쓴이 조회 수 추천 수sort 날짜
67 Oracle 10G installation admin 36974   2011-12-13
 
66 Oracle 의 ASM 구조 알아보기.. admin 39577   2011-12-13
 
65 오라클 아키텍쳐 admin 35982   2011-12-13
 
64 Oracle ACE 로부터 배우기 admin 39032   2011-12-16
 
63 Oracle Preinstallation Tasks admin 33243   2011-12-16
 
62 Oracle 의 ASM 구조 알아보기.. admin 40204   2011-12-16
 
61 Oracle 설치 Centos ,openSUSE,엔터프라이즈등 퍼온글 admin 36394   2011-12-16
 
60 xhost and display admin 34620   2011-12-16
 
59 (C#) ASP.NET MySQL Check Already Exists Add/Insert Record 프로그래밍 코드 admin 34387   2011-12-19
 
58 Java && Excel 연동 JAVA 자바로 엑셀을 핸들링 할 수 있는 방법 admin 192109   2011-12-19
 
57 http://www.hoons.kr/ admin 34547   2011-12-19
 
56 Oracle Backup & Restore admin 87271   2012-02-07
 
55 오라클 ACE가 해설하는 Oracle Backup & Recovery admin 41030   2012-02-07
 
54 Oracle Backup & restore with RMAN 기본 admin 41711   2012-02-12
 
53 Oracle RHEL4+10G 10.2.0.1 설치 10.2.0.5 패치 admin 94579   2012-03-03
 
52 Upgrade Oracle 10g Release 2 from 10201 to 10204 admin 110156   2012-03-05
 
51 centos 6.2 oracle 10g 설치 admin 108040   2012-03-05
 
50 Upgrade Oracle from 10.2.0.1 To 10.2.0.4 (Windows) admin 163472   2012-03-06
 
49 SUSE Linux Enterprise Server 10 (Oracle 10g R2 (10.2.0.1)) file admin 37178   2012-03-09
 
48 Oracle 10g Articles admin 31775   2012-06-24
 
47 기본 10g 설치의 리눅스 세팅에서 추가 해줘야하는 사항(윈도우) admin 39185   2012-06-24
 
46 Connect Excel VBA to a MySQL database file admin 45241   2013-09-05
 
45 MySQL Java tutorial admin 48229   2012-09-30
 
44 Configuring Oracle ASM disks in Oracle Enterprise Linux admin 37993   2013-04-20
 
43 PreparedStatement mysql java 깔끔한설명 admin 105003   2013-10-26
 
42 Oracle Linux 에 Oracle DB 설치하기 admin 103960   2013-12-03
 
41 OLE5 + 11G 설치 _silent mode admin 83619   2013-04-08
 
40 RHEL4 + 10g 설치 _silent mode admin 80460   2013-04-08
 
39 OS에따른 Oracle 설치버전 admin 31766   2013-04-08
 
38 SUPER OCM 1.8club admin 30799   2012-12-18