//데이터 던지는 부분~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

package exam.ProductList;

import android.app.Activity;
import android.content.Intent;
import android.database.*;
import android.database.sqlite.*;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;

public class ProductList extends Activity {
    /** Called when the activity is first created. */
ProductDBHelper mHelper;   //생성
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mHelper = new ProductDBHelper(this);  // 사용하기 위해 생성
        final Cursor cursor;  // 커서생성
        SQLiteDatabase db = mHelper.getWritableDatabase(); //db 생성
        
        cursor = db.rawQuery("SELECT * FROM product", null);
        startManagingCursor(cursor);
        
        SimpleCursorAdapter Adapter = null;
        Adapter = new SimpleCursorAdapter(this,android.R.layout.simple_list_item_2,
         cursor , new String[]{"name","price"},
         new int[]{android.R.id.text1 , android.R.id.text2});
        ListView list = (ListView)findViewById(R.id.list);
        list.setAdapter(Adapter);
        
        list.setOnItemClickListener(new OnItemClickListener() {
        
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
{
Intent intent = new Intent(ProductList.this , ProductView.class);
// intent.putExtra("product", Long.toString(id));
intent.putExtra("product", cursor.getString(cursor.getColumnIndex("_id")));
Log.e("idx", cursor.getString(cursor.getColumnIndex("_id")));
startActivity(intent);
}
});
    }
    
}

//받는부분-==================================================


package exam.ProductList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;


public class ProductView extends Activity 
{
    /** Called when the activity is first created. */
ProductDBHelper mHelper;   //생성
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Intent intent = getIntent();
        int id = intent.getStringExtra("product", 0);
        
        Log.e("id", ""+id);
    }    
}

///////////////////////////로그

11-23 08:28:28.656: WARN/Bundle(1319): Key product expected Integer but value was a java.lang.String.  The default value 0 was returned.
11-23 08:28:28.666: WARN/Bundle(1319): Attempt to cast generated internal exception:
11-23 08:28:28.666: WARN/Bundle(1319): java.lang.ClassCastException: java.lang.String
11-23 08:28:28.666: WARN/Bundle(1319):     at android.os.Bundle.getInt(Bundle.java:855)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.content.Intent.getIntExtra(Intent.java:3175)
11-23 08:28:28.666: WARN/Bundle(1319):     at exam.ProductList.ProductView.onCreate(ProductView.java:22)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.os.Looper.loop(Looper.java:123)
11-23 08:28:28.666: WARN/Bundle(1319):     at android.app.ActivityThread.main(ActivityThread.java:4363)
11-23 08:28:28.666: WARN/Bundle(1319):     at java.lang.reflect.Method.invokeNative(Native Method)
11-23 08:28:28.666: WARN/Bundle(1319):     at java.lang.reflect.Method.invoke(Method.java:521)
11-23 08:28:28.666: WARN/Bundle(1319):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-23 08:28:28.666: WARN/Bundle(1319):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-23 08:28:28.666: WARN/Bundle(1319):     at dalvik.system.NativeStart.main(Native Method)




책 내용의 샘플로 아이템 클릭 구성만 더한것인데요..
우선 , 더미로 하나 만들어놓으려고 합니다.

문제는..

받는 부분에서 id 값이 "0" 이나 "-1" 이 찍히네요.

db 로 리스트 구성하고 클릭하면 , 데이터를 넘기는것을 구성하려고 합니다..


조언 부탁드립니다.