A> SQL lite 사용
1.db 선언
SQLiteDatabase db=openOrCreateDatabase("memodb", MODE_PRIVATE, null);
2. 수행
-- rawQuery(String sql, String[] selectionArgs): select SQL 수행
-- execSQL(String sql): insert, update 등 select 문이 아닌 나머지 SQL 수행
예시
db.execSQL("insert into tb_memo (title, content) values (?,?)", new String[]{title, content});
3.커서 이용
예시
Cursor cursor= db.rawQuery("select title, content from tb_memo order by _id desc limit 1", null);
--
Cursor는 선택된 행(row)의 집합 객체
• moveToNext(): 순서상으로 다음 행 선택
• moveToFirst(): 가장 첫 번째 행 선택
• moveToLast(): 가장 마지막 행 선택
• moveToPrevious(): 순서상으로 이전 행 선택
B> SQLiteOpenHelper 클래스
-- 테이블 생성이나 스키마 변경 등의 작업
2. 메소드
---insert(String table, String nullColumnHack, ContentValues values)
---update(String table, ContentValues values, String whereClause, String[] whereArgs)
---delete(String table, String whereClause, String[] whereArgs)
---query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
== 쿼리는 select 와 비슷한 역할
D>Realm 사용하기
1.그레이들에 depenecy 주입