Skip to main content

Posts

Showing posts from December, 2019

MediaStore.Images.保存图片时生成两张图片的问题 并且在oppo手机上时间是1970-01-01 08:00:00

MediaStore.Images.保存图片时生成两张图片的问题 并且在oppo手机上时间是1970-01-01 08:00:00 正确方式如下 使用方式一 private void saveImage( String originFilePath) { File appDir = new File ( Environment . getExternalStorageDirectory() . getPath() + " /leikebaijing/images " ); if ( ! appDir . exists()) appDir . mkdirs(); String fileName; long dateTaken = System . currentTimeMillis(); if (originFilePath . contains( " / " )) { fileName = originFilePath . substring(originFilePath . lastIndexOf( " / " ) + 1 ); } else { fileName = dateTaken + " jpg " ; } File file = new File (appDir, fileName); if ( ! file . exists()) { try { file . createNewFile(); } catch ( IOException e) { e . printStackTrace(); }