tag:blogger.com,1999:blog-3063681411154454825.post8444056130025883085..comments2019-06-22T01:07:57.997-07:00Comments on Android-Java: android application to connect to your own sqlite database created externllySunnyhttp://www.blogger.com/profile/17154041223379220854noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-3063681411154454825.post-85897342962561294542013-12-25T00:13:05.880-08:002013-12-25T00:13:05.880-08:00Force close error is going On
Force close error is going On<br />Anonymoushttps://www.blogger.com/profile/05227775286626567938noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-56636144222290645652013-08-01T11:26:21.566-07:002013-08-01T11:26:21.566-07:00I know how to iterate using cursor.isFirst and cur...I know how to iterate using cursor.isFirst and cursor.moveToNext. How to iterate using cursor.moveToPosition(x)? I would really appreciate your reply.Thanks<br /><br />//Mydatabase.java<br /><br />public Cursor getData(int _id) {<br /> SQLiteDatabase db = this.getReadableDatabase();<br /> <br /> <br /> <br /> Cursor cursor =db.rawQuery("Select * from '"+DB_TABLE+"' where _id = ?", new String[] { String.valueOf(_id)}); <br /> <br /> if (cursor != null)<br /> {<br /> cursor.moveToFirst();<br /> }<br /> <br /> return cursor;<br /> }<br /><br /><br />//MyActivity.java<br /><br />public void onClick(View v) {<br /> cur=db.getData(position);<br /> int firstpos=1; <br /> int lastpos=4;<br /><br /> switch(v.getId())<br /> {<br /><br /> case R.id.next :<br /> { <br /><br /> if (cur != null && cur.getCount()> 0 && position < cur.getCount() && position != cur.getCount()){<br /> cur.moveToPosition(position);<br /> textView1.setText(""+cur.getString(1));// Display Columns <br /> position++;<br /> cur.moveToNext();<br /> }<br /> if(cur.moveToPosition(lastpos))<br /> {<br /><br /> cur.moveToPosition(firstpos); <br /> textView1.setText(""+cur.getString(1));<br /> }<br /> /*else<br /> {<br /> cur.moveToPosition(position); <br /> textView1.setText(""+cur.getString(1));<br /> position++;<br /> }*/<br /><br /><br /> //display details code<br /><br /> }<br /> break;<br /> case R.id.random:<br /> {<br /> Random r = new Random();<br /> int rnum = r.nextInt(max - min + 1) + min;<br /> cur=db.getData(rnum);<br /> setNewData(rnum);<br /> }<br /> }<br /><br /><br /> }<br /><br />private void setNewData (int xyz) {<br /><br /> <br /><br /> }<br />Manish and Nidhihttps://www.blogger.com/profile/13941731569149218541noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-41515346072539142612013-06-17T08:51:08.983-07:002013-06-17T08:51:08.983-07:00Hi Manish And Nidhi, To fetch from multiple column...Hi Manish And Nidhi, To fetch from multiple column <br /><br />Cursor c = db.query(YOUR_TABEL_NAME, new String[] {YOUR_COLUMN_1,YOUR_COLUMN_2...and so on}, null, null,null,null);<br />while(c.moveToNext()) {<br /><br />fetch your columns<br />} Sunnyhttps://www.blogger.com/profile/17154041223379220854noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-66782456656481527532013-06-11T16:46:47.467-07:002013-06-11T16:46:47.467-07:00How to fetch blob type image using this example?How to fetch blob type image using this example?Manish and Nidhihttps://www.blogger.com/profile/13941731569149218541noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-73271832294841818242013-06-11T14:43:07.765-07:002013-06-11T14:43:07.765-07:00This tutorial is very helpful. What to do when we ...This tutorial is very helpful. What to do when we want to fetch multiple columns from db?Manish and Nidhihttps://www.blogger.com/profile/13941731569149218541noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-38598513165903762122013-01-20T07:39:01.413-08:002013-01-20T07:39:01.413-08:00this one is showing error database doesnt exist.
N...this one is showing error database doesnt exist.<br />No table foundshantanu sumanhttps://www.blogger.com/profile/07060197062287119110noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-8550057955888470872012-08-13T02:37:49.341-07:002012-08-13T02:37:49.341-07:00Really nice tutorial it help me a lot thanks for t...Really nice tutorial it help me a lot thanks for this please carry onAnonymoushttps://www.blogger.com/profile/13532698002831657122noreply@blogger.comtag:blogger.com,1999:blog-3063681411154454825.post-2355234341357893652012-07-14T03:53:38.386-07:002012-07-14T03:53:38.386-07:00hello this is very grate example to beginners. no...hello this is very grate example to beginners. now just i update in this example.i need to use image from db. how?<br />i have use this code after tv.setText(cur.getString(1));<br />my image field is 3 (blob).my code for image is <br /> tv.setText(cur.getString(1)); <br /> byte[] bb = cur.getBlob(3);<br /> ByteArrayInputStream is = new ByteArrayInputStream(bb);<br /> Bitmap theImage = BitmapFactory.decodeStream(is);<br /> ImageView img = (ImageView)findViewById(R.id.imageView1);<br /> img.setImageBitmap(theImage); <br />but it give "Force Close"<br /> give me some basic idea for that.Anonymousnoreply@blogger.com