DB 연결한 고객정보 프로그램입니다.
프로그램이라고 하기에 민망할 정도인 단순 스터디이지만요~
결국은 모든 프로그램은 DB 연결이네요.
내용이 좀 많습니다. 따라서 2번에 걸쳐서 포스팅 하도록 할게요.
하나씩 차근히 가보도록 하겠습니다
이 포스팅이 도움이 되신다면 추천 한번 부탁드릴게요^^
양질의 정보로 보답하겠습니다.
================== 프로젝트 세팅 =================
프로젝트명 : DBtest
Application name : 고객목록
Pacakage name : com.example.dbtest
(액티비티를 다음과 같이 두 개 만들어주세요.)
Create Activity : CustomerListActivity(고객목록 리스트출력)
Create Activity : CustomerRegActivity(고객등록 리스트출력)
DB연결 class : DBManager.java
(에니아웃을 다음과 같이 두 개 만들어주세요.)
Layout name : main.xml(고객목록 레이아웃)
Layout name : join_form.xml(고객등록 레이아웃)
아래와 같이 맞춰주시면 됩니다.
=========================================================
이번에 사용될 클래스에 대해 간단히 설명볼까 합니다.
SQLiteOpenHelper
데이터베이스 생성과 버전을 관리하는 클래스
SQLiteDatabase
SQLite 데이터베이스를 관리하는 메소드를 제공함
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/customers"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_join_form"
android:text="고객등록"
/>
</LinearLayout>
DBManager.java
package com.example.dbtest;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class DBManager extends SQLiteOpenHelper {
public DBManager(Context ct){
super(ct, "myDB", null, 1);
}//end
@Override
public void onCreate(SQLiteDatabase db) { //create table
db.execSQL("create table customers (name, text, sex text, sms text);");
}//end
@Override
public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
}//end
}//main END
다음 포스팅에 이어가도록 하겠습니다.
'IT > Android' 카테고리의 다른 글
안드로이드 SQLite DB 활용한 고객등록과 조회 3-3 (23) | 2013.07.19 |
---|---|
안드로이드 SQLite DB 활용한 고객등록과 조회 3-2 (0) | 2013.07.19 |
WebView / 웹 문서 / 웹 뷰 (0) | 2013.07.16 |
Android 고객등록/정보전달 02 (0) | 2013.07.15 |
Android(안드로이드) 웹서버 (0) | 2013.07.15 |