Reputation: 1408
I am working on an application which will contain tons of graphics....Its approx size will be 80 MB.Application will download the graphics(Greeting Cards in png format actually) on first start from web service.The problem I am facing is that where to save these graphics (Greeting cards) and how ???Whether to save them in internal storage or SD card or SQLite....My questions are
How to retrieve/access them.
All info of these images will be in SQLite.Also please show me some code.
Upvotes: 1
Views: 3662
Reputation: 3658
Use the below code.
public class ImageDownload {
public static void downloader(String imageURL, String fileName) {
try {
URL url = new URL("http://www.exampleurl.com/" + imageURL);
File file = new File(fileName);
URLConnection con = url.openConnection();
InputStream is = con.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ((current = bis.read()) != -1) {
baf.append((byte) current);
}
FileOutputStream fos = new FileOutputStream(file);
fos.write(baf.toByteArray());
fos.close();
} catch (IOException e) {
Log.d("Downloader", "Error: " + e);
}
}
}
Upvotes: 1
Reputation: 9242
As far as code, you will hardly find anyone on here who is just going to give you teh codez. StackOverflow is for when you get stumped and need help.
Google:
android httpclient
android sqlite
android content provider
Upvotes: 0
Reputation: 7708
Answers below. For code you should search this place and try out few things and get back if it does not work.
Upvotes: 1