Reputation: 11
I want to display images locally. Since i store the images in SD card it will not be available when i build the project.
Is there any other way to store local images other than SDcard, So that the images will be included in build file(.apk file).
GridView mGrid;
private static final String DIRECTORY = "/sdcard/Pictures/";
private static final String DATA_DIRECTORY = "/sdcard/Pictures/.ImageViewFlipper/";
private static final String DATA_FILE = "/sdcard/Pictures/.ImageViewFlipper/imagelist.dat";
Upvotes: 0
Views: 1424
Reputation: 358
public class imagegallery extends Activity {
/** Called when the activity is first created. */
Integer[] imageIDs = {
R.drawable.img1,
R.drawable.img2,
R.drawable.img3,
R.drawable.img4,
R.drawable.img5,
R.drawable.img6
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int position=2;
ImageView imageView = (ImageView) findViewById(R.id.image);
imageView.setImageResource(imageIDs[position]);
}
}
Upvotes: 0
Reputation: 128448
Yes ofcourse you can store images either in Drawable folder or also in Assets folder.
If you stores images in Drawable folder then it will be compiled and index will be generated in R.java file but if you store images inside the assets folder then no index will be generated because assets folder is non-compiled folder.
Upvotes: 1