Get filepath and filename of selected gallery image in Android

Add this class in your project ImageFilePath.java import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.ContentUris; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.provider.DocumentsContract; import android.provider.MediaStore; //import android.provider.<span id=”IL_AD11″ class=”IL_AD”>MediaStore</span>; @SuppressLint(“NewApi”) @TargetApi(Build.VERSION_CODES.KITKAT) public class ImageFilePath { /** * Method for return file path of Gallery image * * @param context * @param uri * … Read more

Getting filesystem path of class being executed [duplicate]

The following code snippet will do this for you: final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath()); replace MyClass with your main class The resulting File object f represents the .jar file that was executed. You can use this object to get the parent to find the directory that the .jar is in.

What does \\?\ mean when prepended to a file path

A long read, but worth reading if you are in this domain: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx Extract: The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value … Read more

Why use os.path.join over string concatenation?

Portable Write filepath manipulations once and it works across many different platforms, for free. The delimiting character is abstracted away, making your job easier. Smart You no longer need to worry if that directory path had a trailing slash or not. os.path.join will add it if it needs to. Clear Using os.path.join makes it obvious … Read more