You are using the logger in several places. Just use it some more - where you want to see values logged in the dev. env.
On Sun, Aug 19, 2012 at 11:46 AM, Sadhna Upadhyay <[email protected]> wrote: > Hi everybody, > > I am creating a database and i have done it, buti dont know > how to print those records on console ,actully i am getting value from > edittext box and i can print those value in Toast but i want to print those > value on simulator when user click on View button to see records pls help me > if any one hava any clue. > > > This is my code > > > package SQliteDemo.s; > > import java.util.Locale; > > import android.app.Activity; > import android.content.ContentValues; > import android.database.Cursor; > import android.database.sqlite.SQLiteDatabase; > import android.os.Bundle; > import android.util.Log; > import android.view.MotionEvent; > import android.view.View; > import android.widget.Button; > import android.widget.EditText; > import android.widget.Toast; > > public class SQliteDemo extends Activity { > /** Called when the activity is first created. */ > SQLiteDatabase sampleDB; > Button btninsert,btn_view; > EditText edtid,etname,passwrd; > int id; > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > > initializeUI(); > > sampleDB=this.openOrCreateDatabase("sampleDB",SQLiteDatabase.CREATE_IF_NECESSARY,null); > sampleDB.setVersion(1); > sampleDB.setLocale(Locale.getDefault()); > sampleDB.setLockingEnabled(true); > String createTable="Create table if not exists USER(id int,name > Varchar,password Varchar);"; > sampleDB.execSQL(createTable); > btninsert.setOnTouchListener(new View.OnTouchListener() { > @Override > public boolean onTouch(View v, MotionEvent event) { > // TODO Auto-generated method stub > //int id=Integer.parseInt(edtid.getText().toString().trim()); > String id1 = edtid.getText().toString().trim(); > id=Integer.valueOf(id1); > String name=etname.getText().toString().trim(); > String pass=passwrd.getText().toString().trim(); > try > { > if (!edtid.equals("")|| edtid!=null){ > // depositAmount1 = Integer.valueOf(costt); > > }} > catch(NumberFormatException ex1) > { > // Uh oh! Bad input! > } > //String sqlForInsert="insert into USER values("+ id +" , "+ name +", > "+pass+");"; > ContentValues values=new ContentValues(); > values.put("id",id); > values.put("name",name); > values.put("password",pass); > > sampleDB.insert("USER"," ", values); > return false; > } > }); > > btn_view.setOnTouchListener(new View.OnTouchListener() { > @Override > public boolean onTouch(View v, MotionEvent event) { > // TODO Auto-generated method stub > String query="select *from USER"; > Cursor cursor=sampleDB.rawQuery(query,null); > String result=""; > cursor.moveToFirst(); > do > { > int id=cursor.getInt(cursor.getColumnIndex("id")); > String name=cursor.getString(cursor.getColumnIndex("name")); > String pass=cursor.getString(cursor.getColumnIndex("password")); > result=id+" |"+name+" |"+pass; > Toast.makeText(getApplicationContext(), result, 9).show(); > Log.d("Result,--------------" + result,"------------"); > } > while(cursor.moveToNext()); > return false;}}); > //return false; > > } > > private void initializeUI() { > // TODO Auto-generated method stub > edtid=(EditText)findViewById(R.id.editText1); > etname=(EditText)findViewById(R.id.editText2); > passwrd=(EditText)findViewById(R.id.editText3); > > btninsert=(Button)findViewById(R.id.button1); > btn_view=(Button)findViewById(R.id.button2); > } > protected void onStop() > { > super.onStop(); > sampleDB.close(); > } > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Michael Banzon http://michaelbanzon.com/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

