I download pictures from the Web and I stored them in the cache. Now, how I can display the photo in the XML. The photos stored as follwing:
/data/data/com.example.app/cache/wpta_i.jpeg
Changes according to the position. My XML is as following:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
</ImageView>
</LinearLayout>
How can I load the image from the cache and display it?
You should load the drawable from code and then setImageDrawable to the ImageView.
String pathName = "/data/data/com.example.app/cache/wpta_i.jpeg";
Drawable d = Drawable.createFromPath(pathName);
ImageView myImageView=(ImageView)findViewById(R.id.img);
myImageView.setImageDrawable(d);