我是Android的新手,我在网格视图上工作,我在网格视图中单击图像时实现了我在String类型的变量“path”中有图像的路径,就像ie / mnt /sdcard/me.jpg如何获取图像的名称,即“me.jpg”,图像的日期请告诉我任何用于此目的的函数或代码。我提到代码以了解路径
gridview.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
path = (String)parent.getItemAtPosition(position);
/*Toast.makeText(getApplicationContext(),
path,
Toast.LENGTH_LONG).show();*/
return false;
}
答案 0 :(得分:0)
首先在谷歌搜索然后只发帖问题....
File file = new File(path );
String name = file.getName(); //here you get the name of the image
Date lastModDate = new Date(file.lastModified()); // here you get the creation or last modified date of the file
Log.i("File last modified @ : "+ lastModDate.toString());