如何将图像路径存储到数组中。因为我正在动态检索图像。n 列出它们。单击一个图像后,我想将其发送到以前的活动。如何存储图像路径?请帮帮我
below is code-
第一个活动- public void importFile(View v){
Intent intent=new Intent(this,ImportFile.class);
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1)
{
String path=data.getDataString();
System.out.println(";;;;;;;;;;;;"+path);
}
}
第二个活动——
in oncreat-
int j=0;
File[] imagefile;
File f = new File("/sdcard");
File[] files = f.listFiles();
for(int i = 0; i < files.length; i++,j++) {
File file1 = files[i];
if(myfile.endsWith(".jpeg")){
image[j]=file1;//here i'm getting nullpointer exception
}
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int j;
// TODO Auto-generated method stub
for(j=1;j<idcount;j++){
if(ch[j].isChecked())
{
imagesPaths.add(image[++j].getAbsolutePath());
i=new Intent();
i.putExtra("files",imagesPaths);
setResult(RESULT_OK, i);
finish();
}
}
}