Hi I wanted to change the image of my ImageView using a path I have saved on my SQLite database. Well what I want to achieve is for this runs per second whenever the image i
check this if it helps you.
preview.setImageURI(Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Echo/Images/"+file_name));
that how i do it...
public final static String APP_PATH_SD_CARD = "/DesiredSubfolderName/";
public final static String APP_THUMBNAIL_PATH_SD_CARD = "thumbnails";
public boolean saveImageToExternalStorage(Bitmap image) {
String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + APP_PATH_SD_CARD + APP_THUMBNAIL_PATH_SD_CARD;
try {
File dir = new File(fullPath);
if (!dir.exists()) {
dir.mkdirs();
}
OutputStream fOut = null;
File file = new File(fullPath, "desiredFilename.png");
file.createNewFile();
fOut = new FileOutputStream(file);
// 100 means no compression, the lower you go, the stronger the compression
image.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), file.getName(), file.getName());
return true;
} catch (Exception e) {
Log.e("saveToExternalStorage()", e.getMessage());
return false;
}
}