tags:

views:

29

answers:

1

Hai Friends, I am parsing the website to store the contents in a url, in that some images are there, i want to store the images in database which are parsed from the site. i m really struggling on this, cany any one help me regarding on this

A: 

First you'll want to override SQLiteOpenHelper to create and access a database, as described briefly here. You can store your database anywhere you want within your app's directory, but if you use this helper class it will automatically create the database at the recommended location of "/data/data/your.package.name/databases" (which you can retrieve at runtime by calling Context.getDatabasePath).

So now you have a database and it has a table "Images," and let's say this table has a "URL" column of type String and a "data" column of type Blob, plus maybe an auto-incremented "_ID" column.

Now you need to download the image. If you don't have the code to do this, you'll want to learn how to use Apache's HTTPClient libraries to issue GET requests. Find the official Apache tutorial here, and have a look at the HttpGet class. At the end of this you should have a byte array containing the raw image data. Once you have that, you just need to run the following code:

ContentValues values = new ContentValues();
values.put("URL", urlString);
values.put("data", imgData);

SQLiteDatabase db = helper.getWritableDatabase();
db.insert("Images", null, values);
Neil Traft
Thank U Very Much Mr.NEil Traft
Tilsan The Fighter