Move/Rename file in SD Card
// this the uri, something like content://media/external/images/media/635
What you are then doing is trying to concatenate this onto Environment.getExternalStorageDirectory()
. This will not work. content://media/external/images/media/635
is neither a relative filesystem path nor an absolute filesystem path. It is a Uri
.
If you wish to copy the image from the Uri
to a local file, use a ContentResolver
to get an InputStream
on the image represented by the Uri
, then use Java I/O to copy the bytes from the InputStream
to your target file.
Rename folder in SD card
File file = new File("your old file name");
File file2 = new File("your new file name");
boolean success = file.renameTo(file2);
android, How to rename a file?
The problem is in this line,
File from = new File(directory, "currentFileName");
Here currentFileName
is actually a String you dont have to use "
try it this way,
File from = new File(directory, currentFileName );
^ ^ //You dont need quotes
Related Topics
Error Java.Lang.Runtimeexception: Stub! in Android with Fitnesse Testing
Convert String into Localdatetime
Can't Find Toolbar in an Included Layout
Runonuithread VS Looper.Getmainlooper().Post in Android
Error:Program Type Already Present: Android.Support.Design.Widget.Coordinatorlayout$Behavior
How to Draw Road Directions Between Two Geocodes in Android Google Map V2
Android Viewpager Get the Current View
Android Kitkat 4.4 Hangouts Cannot Handle Sending Sms Intent
Android Crash When App Is Closed and Reopened
How How to Do Ussd Requests on Android
Fire a Pinch In/Out Command to Android Phone Using Adb
Launch Android Application from a Browser Link
Sqlite Example Program in Android
How to Disable Home Button in Android
Android: How to Maximize Preferencefragment Width (Or Get Rid of Margin)