차근차근/Android

[ study ] 다이어리 어플 만들어보기 1 - 부가 설명 4

예쁜꽃이피었으면 2015. 4. 24. 14:32


java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.


while (cursor.moveToNext()) {  
 int bookId = cursor.getInt(cursor.getColumnIndex("bookiD"));
}




SQLite 2탄 – 데이터와 인덱스 구조!!

http://gywn.net/2013/09/let-me-know-data-index-of-sqlite/


- sqlite 의 각각의 row는 고유의 8byte 정수 타입으 rowID를 가진다.

- rowID 순서로 데이터가 저장된다.

- RowId는 "내부적"으로 관리된다. 그러나.. 반드시 내부적으로 관리되는 것도 아니다?

- Primary Key가 정수 타입인 경우 primary key가 rowid의 역할을 대체한다.




Intent로 데이터 전달( putExtra , getExtras), TapHost에서 다른 액티비티로 변수값 전달

http://pds0819.tistory.com/entry/%EC%9D%B8%ED%85%90%ED%8A%B8Intent%EB%A1%9C-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%A0%84%EB%8B%ACputExtra-getExtras-%EA%B7%B8%EB%A6%AC%EA%B3%A0-TapHost%EC%97%90%EC%84%9C-%EB%8B%A4%EB%A5%B8-%EC%97%91%ED%8B%B0%EB%B9%84%ED%8B%B0%EB%A1%9C-%EB%B3%80%EC%88%98%EA%B0%92-%EC%A0%84%EB%8B%AC


1. 인텐트로 다른 액티비티를 실행시킬 때 (ex. AnotherActivity.class => 다른 액티비티)

Intent intent = new Intent(getApplicationConText(),AnotherActivity.class);

strarActivity(intent);


2. AnotherActivity.class 에 데이터 전달 => putExtra() 사용

Intent intent = new Intent(getApplicationContext(),AnotherActivity.class);

Intent.putExtra("name","아이고");

Intent.putExtra("age",22);

startActivity(intent);


3. AnotherActivity.class 에서 데이터 받기 => getExtras() 사용 (onCreate()메서드에 구현)

Intent intent = getIntent();

String name = intent.getExtras().getString("name");

int age = intent.getExtras().getInt("age");



column '_id' does not exist

Android SQLite :  http://enosent.tistory.com/12


column '_id' does not exist 해결방법 : http://ralf79.tistory.com/244


column '_id' does not exist 예외 발생 : http://www.androidpub.com/20313


SimpleCursorAdapter 사용시 column '_id' does not exist 에러가 뜨면? : 

http://androidhuman.tistory.com/entry/SimpleCursorAdapter-%EC%82%AC%EC%9A%A9%EC%8B%9C-column-id-does-not-exist-%EC%97%90%EB%9F%AC%EA%B0%80-%EB%9C%A8%EB%A9%B4




public Cursor getAllData() {

String buildSQL = "SELECT _id, * FROM " + TABLE_NAME + ";";

   return database.rawQuery(buildSQL, null);

}

//  검색할 때 _id 추가하니까 textview에 출력됐다! 대박



/* 다시 수정 */

보니까 음.. 이미 id값이 0번에 들어가 있음 .  그러니까 나는

_id | _id | title | content 이렇게 칼럼을 4개 만들것이다. ..

음.. id값 꺼내올 때 TextView_id.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(0))));

0번째 칼럼을 가져오면 된다. 하.. 삼일걸린듯..



No package identifier when getting value for resource


Android No package identifier when getting value for resource number 0x00000000 : http://westwoodforever.blogspot.kr/2012/10/android-no-package-identifier-when.html


반응형