【发布时间】:2018-04-05 10:58:30
【问题描述】:
我遇到了一个奇怪的问题,我将图像上传到文件夹并将名称(用户的 id)和扩展名保存在数据库中,并且工作正常,但是当我更改图像时,它在文件夹,但手机中的图像没有改变,尽管我正在编辑保存图像名称和扩展名的 SharedPrefManger。
这是我如何更改文件夹中的图像及其工作正常
String uploadId = UUID.randomUUID().toString();
String path = getPath(filepath);
try {
new MultipartUploadRequest(this,uploadId,Constants.URL_UPLOADPIC)
.addFileToUpload(path,"image")
.addParameter("id",SharedPrefManager.getInstance(this).getKeyUserId())
.setNotificationConfig(new UploadNotificationConfig())
.setMaxRetries(2)
.startUpload();
String extention = path.substring(path.lastIndexOf("."));
String id = SharedPrefManager.getInstance(getApplicationContext()).getKeyUserId();
SharedPrefManager.getInstance(getApplicationContext()).uploadpicmanager(id+extention);
Toast.makeText(Profile.this, path, Toast.LENGTH_LONG).show();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
这里是修改图片名称的上传图片
public boolean uploadpicmanager(String id){
SharedPreferences sharedPreferences3 = mCtx.getSharedPreferences(SHARED_PREF_NAME,Context.MODE_PRIVATE);
SharedPreferences.Editor editor3 = sharedPreferences3.edit();
editor3.putString(KEY_IMAGE,id);
editor3.apply();
return true;
}
这是我如何读取图像及其在第一次上传时工作正常,但是当我更改图片时它不会改变。我想知道如果它不再在文件夹中,它从哪里获取图像??
Picasso.with(getApplicationContext())
.load("http://hello.000webhostapp.com/Shop&Go/customers/"+
SharedPrefManager.getInstance(getApplicationContext()).getKeyImage())
.into(profilepic);
【问题讨论】: