2013-04-20 54 views
4

我正在制作一个应用程序,我正在使用ImageLoading Framework从服务器下载图片将Urls放入缓存...现在我想要用户的个人资料图片更新,但即使更新了个人资料图片在服务器上它不显示在应用程序中。应用程序正在显示用户的旧配置文件图片。为什么会出现这个问题,我该如何解决问题?请尽快帮助。如果这对我有帮助,也请发布链接。更新用户的个人资料图片

在此先感谢!对于更新

代码的onclick:

update_profile_pic.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); 
     String value_for_test="delete"; 
     Toast.makeText(getBaseContext(), "it works", Toast.LENGTH_SHORT).show(); 
     Intent i=new Intent(getApplicationContext(),ProfilePictureCaptureHomeActivity.class); 
     i.putExtra("image",value_for_test); 
     startActivity(i); 

用户照片CaptureHome

DBAdapter db = new DBAdapter(getApplicationContext()); 
db.open(); 
if (null == phoneNumber) 
{ 
    Cursor c = db.getUserInfo(); 
    phoneNumber = c.getString(0); 
    imageUrl = c.getString(1); 

    System.out.println("the imageUrl is"+imageUrl); 
    c.close(); 
} 
setContentView(R.layout.profilepic_capture); 
if (null == imageUrl) 
{ 
    Cursor imageUrlObj = db.getUserInfo(); 
    imageUrl = imageUrlObj.getString(1); 
    System.out.println("the imageurl is"+imageUrl); 

    imageUrlObj.close(); 
} 
db.close(); 

用于更新资料图片:

if(image!=null){ 
    Toast.makeText(getApplicationContext(), "Redirected", Toast.LENGTH_LONG).show(); 
    imageUrl=null; 
} 
if(imageUrl != null) 
{ 
    Intent uploadimg = new Intent(ProfilePictureCaptureHomeActivity.this,ListeningAndSharingHomeActivity.class); 
    uploadimg.putExtra("phoneNumber", phoneNumber); 
    startActivity(uploadimg); 
} 
else 
{ 
    Log.v("ProfilePictureCaptureHomeActivity", "Staying Here"); 
} 

_gallerybutton = (ImageButton) findViewById(R.id.btn_gallery); 
_photobutton = (ImageButton) findViewById(R.id.btn_photo); 
System.out.println("here in popup phoneeeeee" + phoneNumber); 
System.out.println("here in flag************" + firstUpload); 

_gallerybutton.setOnClickListener(new OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); 
     System.out.println("here in galleryyyyyyyyyy"); 
     Intent uploadimg = new Intent(ProfilePictureCaptureHomeActivity.this,ProfilePicFromGallery.class); 
     uploadimg.putExtra("phoneNumber", phoneNumber); 
     startActivity(uploadimg); 
    } 
}); 

_photobutton.setOnClickListener(new OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); 
     System.out.println("here in take piccccc"); 
     Intent capIntent = new Intent(ProfilePictureCaptureHomeActivity.this,ProfilePicFromCamera.class); 
     startActivity(capIntent); 
    } 
}); 
+0

你能发布你的代码片段吗? – itsrajesh4uguys 2013-04-22 05:23:25

+0

我已编辑的代码库,请现在看到问题..配置文件图片正在更新,但只有在清除缓存后..我已经在columnindex 1 .. – Alpesh 2013-04-22 06:27:50

+0

存储在数据库中的配置文件的网址您正在使用相同的名称的配置文件图片保存或不同的名称? – itsrajesh4uguys 2013-04-22 06:29:57

回答

0

看看这段代码。

private String deleteExistingFile(String url , Context context) 
{ 


    String SaveFolderName = context.getFilesDir().getAbsolutePath() + "/yourinternalmemoryfolder"; 

    String str_randomnumber= url.substring(url.lastIndexOf("/") + 1); 
    File wallpaperDirectory = new File(SaveFolderName); 
     if (!wallpaperDirectory.exists()) 
     wallpaperDirectory.mkdirs();     
    String Photo_ImagePath=SaveFolderName+"/" + str_randomnumber ;     


    String result = ""; 
    System.out.println("file path to be deleted " + Photo_ImagePath); 

     File f = new File(Photo_ImagePath); 
      if (f.exists()) 
      { 
       System.out.println(" EEEEEEEEEEXXXXXXXXIIIIISSSSSSSTTTTTTT "); 
      try { 
      if(f.delete() == true){ 
       result = "Success"; 
      }else{ 
       result = "Failure"; 
      } 

      } 

      catch (Exception e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 

      return "Error"; 
     } 

      } 

      System.out.println("deleting existing file " + result); 
     return result; 

} 
+0

谢谢,刚过实施它我会尽快回复你.. – Alpesh 2013-04-22 07:21:59

+0

'selectBtn.setOnClickListener(new View.OnClickListener(){ \t \t \t @Override \t \t \t公共无效的onClick(查看为arg0){ \t \t \t \t的ShowDialog(PROGRESSDIALOG_ID); 代码 \t \t \t \t \t \t \t} \t \t});'应用程序是crashing..when点击上传个人资料piture .. – Alpesh 2013-04-22 08:40:09

+0

为什么您使用的ShowDialog在那里? – itsrajesh4uguys 2013-04-22 08:50:54

相关问题