I read many stack overflow posts saying that inserting images in database is bad
Storing Images in DB - Yea or Nay and Storing image in database directly or as base64 data? and many others.
the thing is still not obvious for me where to save the image ? in a file in server ?. in my application the user will upload several images and see them in his profile.
an example will be much appreciate.
what I did for now ( I now its not that good but I am learning..)
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want.
byte [] byte_arr = stream.toByteArray();
String image_str = Base64.encodeToString(byte_arr, Base64.DEFAULT);
//fnish inserting
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("username", name));
nameValuePairs.add(new BasicNameValuePair("password", pass));
nameValuePairs.add(new BasicNameValuePair("email", emails));
nameValuePairs.add(new BasicNameValuePair("image", image_str));
System.out.println(nameValuePairs);
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://justedhak.comlu.com/users.php");
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
System.out.println(response);
HttpEntity entity = response.getEntity();
} catch (ClientProtocolException e) {
} catch (IOException e) {