Edit: It DOES update, but with a delay of a few hours..
Another Edit;
It happens only on my nexus 4, I tested it today on my SGS1 and it works just as it should. What could be the problem?
You could say its a little complicated so read carefully:
I have an app that uploads an image to the net, (the image can be anything, from user's device).
I have now added an edit function to that structure, where the user can also upload a new image if he would like to change the old one.
It DOES work.. I tested it through my browser, and the image on the server DOES change.
but on the other hand, on the app, for some reason it does not (the image doesnt change, even though the image on the server has now changed and the previous image doesnt exist anymore.).
Its like, it is saved in the device's cache or something.. BUT:
I have no idea how this is happening because the function that downloads the image stars all over again every time I call it.
How come this is happening?
if anyone wants my ImageDownloader
function (but Im hundred precent sure the problem is not there):
private Bitmap downloadBitmap(String url) {
// initilize the default HTTP client object
final DefaultHttpClient client = new DefaultHttpClient();
// forming a HttoGet request
final HttpGet getRequest = new HttpGet(url);
try {
HttpResponse response = client.execute(getRequest);
// check 200 OK for success
final int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
Log.w("ImageDownloader", "Error " + statusCode
+ " while retrieving bitmap from " + url);
return null;
}
final HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream inputStream = null;
try {
// getting contents from the stream
inputStream = entity.getContent();
// decoding stream data back into image Bitmap that
// android understands
final Bitmap bitmap = BitmapFactory
.decodeStream(inputStream);
return bitmap;
} finally {
if (inputStream != null) {
inputStream.close();
}
entity.consumeContent();
}
}
} catch (Exception e) {
// You Could provide a more explicit error message for
// IOException
getRequest.abort();
Log.e("ImageDownloader", "Something went wrong while"
+ " retrieving bitmap from " + url + e.toString());
}
return null;
}
And my Edit.php
file that updates the data, including the image (it works, tested.):
<?php
//1. create connection
$connection=mysql_connect("localhost","lalala","lalala");/
if(!$connection)
{
die("database connection failed:" . mysql_error());
}
$db=mysql_select_db("lalala",$connection);
if(!db)
{
die("database connection failed:" . mysql_error());
}
mysql_query("SET NAMES 'utf8'",$connection);
if ($_POST["lala"]!=null)
{
if ($_POST["lalala"]!=null && $_POST["lalala"]!=null)
{
$sql="UPDATE `lalala`.`lalal` SET `xxx` = '".$_POST[xxx]."', `xxx`='".$_POST[xxx]."', `xxx` = '".$_POST[xxx]."', `xxx`='".$_POST[xxx]."', `xxxt`='".$_POST[xxx]."', `xxx`= '".$_POST[xxx]."', `xxx` = '".$_POST[xxx]."' WHERE `xxx`.`xx` = ".$_POST[xx].";";
$result=mysql_query($sql,$connection);
if(!$result)
{
echo "error.";
//echo "('".mysql_insert_id($connection)."','".$_POST[title]."','".$_POST[snippet]."','".$_POST[cat]."','".$_POST[desc]."','".$_POST[lat]."','".$_POST[lon]."','".$_POST[pub]."','0','0','".$_POST[program]."','".$_POST[addr]."')\n";
die("database connection failed:" . mysql_error());
}
else {
if ($_POST[isnewimg]==1)
{
if (unlink("upload/id".$_POST[id].".jpg"))
{
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name'].$_POST[id].".jpg");
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "1";
}
else {echo "Img update failed".$_POST[id];}
}
else {echo "Img deletion failed".$_POST[id];}
}
else
echo "1"."w/o image. updated ".$_POST[id];
}
}
}
else {
echo "2";
}
mysql_close($connection);
?>