i am making an android chat application that shows list of friends with image from mysql database..... i want to also store it locally i just want to know if i show store the images in the sqlite database or on the sdcard and save the path in the sqlite database .... I know saving the path is better but the thing is the user can delete the folder or some images int the folder which i dont want any advice.
and this is the code i found that should work
DefaultHttpClient mHttpClient = new DefaultHttpClient();
HttpGet mHttpGet = new HttpGet("your image url");
HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet);
if (mHttpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = mHttpResponse.getEntity();
if ( entity != null) {
// insert to database
ContentValues values = new ContentValues();
values.put(MyBaseColumn.MyTable.ImageField, EntityUtils.toByteArray(entity));
getContentResolver().insert(MyBaseColumn.MyTable.CONTENT_URI, values);
}
}
Aucun commentaire:
Enregistrer un commentaire