Reputation: 265
how to store multiple images in sdcard from internet and store the path in database? can For multiple images, how should i do? Till now what i did is..
Table Create Query is Below:
"create table table1 (_id integer primary key autoincrement, "
+ "title text not null, definition text not null, image BLOB not null);";
but for storing one value i have inserted as
bmOptions = new BitmapFactory.Options();
bmOptions.inSampleSize = 1;
bm = Loadmage(image_URL, bmOptions);
mImageV.setImageBitmap(bm);
extStorageDirectory = Environment.getExternalStorageDirectory().toString();
OutputStream outStream = null;
File file = new File(extStorageDirectory, "er.PNG");
try{
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
So for all the title the same image is showing...I want to display different images for different titles..
Upvotes: 1
Views: 1777
Reputation: 34026
You have to use the name of the image as the name at server. You have to just concat the image name with the directory
for example
Suppose you have image name rose.jpg
and if you want to save it on SD card then
File file = new File(Environment.getExternalStorageDirectory(), "/backup/" + rose.jpg);
and then you can store path of file name like
String path = file.getAbsolutePath();
Upvotes: 1