Thingse/app/src/main/java/com/daneshzaki/thingse/EditSomething.java
//copy image selected to thingse folder
copy image selected to thingse folder
copy image selected to thingse folder
private String copySelectedImageToThingse(String selPicLocation)
	{
		File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), ".Thingse");
		if (! mediaStorageDir.exists())
		{
			if (! mediaStorageDir.mkdirs())
			{
				Log.d("EditSomething", "failed to create directory");
				return null;
			}
		}
		try
		{
			File noMedia = new File(mediaStorageDir.getPath() + ".nomedia");
			if(!noMedia.exists())
			{
				FileWriter f = new FileWriter(noMedia);
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
		File destination = new File(mediaStorageDir.getPath() + File.separator + "IMG_"+ timeStamp + ".jpg");
		picLocation = destination.getAbsolutePath();
		try
		{
			File source = new File(selPicLocation);
			if (source.exists())
			{
				FileChannel src = new FileInputStream(source).getChannel();
				FileChannel dst = new FileOutputStream(destination).getChannel();
				dst.transferFrom(src, 0, src.size());
				src.close();
				dst.close();
			}
			compressFile(destination);
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		Log.i("EditSomething", "copySelectedImageToThingse file created"+picLocation);
		return picLocation;
	}
private String copySelectedImageToThingse ( String selPicLocation ) { File mediaStorageDir = new File ( Environment . getExternalStoragePublicDirectory ( Environment . DIRECTORY_PICTURES ) , ".Thingse" ) ; if ( ! mediaStorageDir . exists ( ) ) { if ( ! mediaStorageDir . mkdirs ( ) ) { Log . d ( "EditSomething" , "failed to create directory" ) ; return null ; } } try { File noMedia = new File ( mediaStorageDir . getPath ( ) + ".nomedia" ) ; if ( ! noMedia . exists ( ) ) { FileWriter f = new FileWriter ( noMedia ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } String timeStamp = new SimpleDateFormat ( "yyyyMMdd_HHmmss" ) . format ( new Date ( ) ) ; File destination = new File ( mediaStorageDir . getPath ( ) + File . separator + "IMG_" + timeStamp + ".jpg" ) ; picLocation = destination . getAbsolutePath ( ) ; try { File source = new File ( selPicLocation ) ; if ( source . exists ( ) ) { FileChannel src = new FileInputStream ( source ) . getChannel ( ) ; FileChannel dst = new FileOutputStream ( destination ) . getChannel ( ) ; dst . transferFrom ( src , 0 , src . size ( ) ) ; src . close ( ) ; dst . close ( ) ; } compressFile ( destination ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } Log . i ( "EditSomething" , "copySelectedImageToThingse file created" + picLocation ) ; return picLocation ; }
copy image selected to thingse folder
copy image selected to thingse folder
// Create the storage directory if it does not exist //create a nomedia file to show // Create a media file name //if src file exists //copy from src to dst file