无法获取图像的名称和日期

时间:2013-05-06 14:32:06

标签: android gridview android-sdcard

我是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;
        }

1 个答案:

答案 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());