sd-card

Clear out android Downloads list

两盒软妹~` 提交于 2019-12-02 03:25:34
I am trying to make an application that will do some cleanup on my device among other things I would like it to delete all of the files residing in my Download dir. I use a method like this to delete the files: private static void deleteFiles(File path) { Util.Log("deleting all files underneath " + path.getName()); if( path.exists() && path.isDirectory() ) { File[] files = path.listFiles(); for(int i=0; i<files.length; i++) { if(files[i].isDirectory()) { Util.Log(files[i].getName() + " is a dir, being recursive."); deleteFiles(files[i]); }else { Util.Log(files[i].getName() + " is a file,

Deleting file from sdcard in android

流过昼夜 提交于 2019-12-02 02:34:53
问题 I am making an app in which I have to delete the recently added mp3 file in sdcard. The format in which the song is saved is: Songhello_17_26.amr where 17_26 is the time when song was added. Can anyone help me how delete the recently added file in sdcard. I mean to say that I want to delete the time means the latest added file should get deleted. Any help will be appreciated. 回答1: As it states here, you cant do that directly, you first need to get list of files File.listFiles() , Comparator ,

Deleting file from sdcard in android

核能气质少年 提交于 2019-12-01 21:22:55
I am making an app in which I have to delete the recently added mp3 file in sdcard. The format in which the song is saved is: Songhello_17_26.amr where 17_26 is the time when song was added. Can anyone help me how delete the recently added file in sdcard. I mean to say that I want to delete the time means the latest added file should get deleted. Any help will be appreciated. Mohammed Azharuddin Shaikh As it states here , you cant do that directly, you first need to get list of files File.listFiles() , Comparator , File.lastModified() , Arrays.sort() and delete. Edited: File f = new File(path)

Find all files on sd card

血红的双手。 提交于 2019-12-01 19:40:21
问题 I want to find all files stored on sdCard. I used this code: List<File> dir = new ArrayList<File>(); List<File> files = new ArrayList<File>(); File root = new File (Environment.getExternalStorageDirectory().getAbsolutePath()); scan(root); // find root directories for (File f : dir) { // find in root... scan(f); } Log.i("files", "" + files.size()); Log.i("dir", "" + dir.size()); } public void scan (File path) { for (File f : path.listFiles()) { if (f.isFile()) { files.add(f); } else { dir.add

Find all files on sd card

荒凉一梦 提交于 2019-12-01 18:49:08
I want to find all files stored on sdCard. I used this code: List<File> dir = new ArrayList<File>(); List<File> files = new ArrayList<File>(); File root = new File (Environment.getExternalStorageDirectory().getAbsolutePath()); scan(root); // find root directories for (File f : dir) { // find in root... scan(f); } Log.i("files", "" + files.size()); Log.i("dir", "" + dir.size()); } public void scan (File path) { for (File f : path.listFiles()) { if (f.isFile()) { files.add(f); } else { dir.add(f); } } } But I have problem with this exception: "java.util.ConcurrentModificationException" I change

How can I check the app is movable to sd or not

≡放荡痞女 提交于 2019-12-01 14:32:10
I want to know how to check whether the app is movable to sd or not through code. I know how to get the installed applications list and is it on sd card or not. If ApplicationInfo flags contains ApplicationInfo.FLAG_EXTERNAL_STORAGE then it is on sd card but how can I check whether the app is movable to sd or not. My first guess is too look into Android Source code for InstalledAppDetails activity. This is activity which shows "Move to phone" and "Move to SD card" buttons. It has interesting function called initMoveButton : private void initMoveButton() { String pkgName = mAppInfo.packageName;

To save the image in sdcard [closed]

南笙酒味 提交于 2019-12-01 14:26:28
I have Written the code for Editing the Image now I want to save that edited image in the sdcard image=(ImageView)findViewById(R.id.image); Intent intent = getIntent(); File sdCardDirectory = Environment.getExternalStorageDirectory(); photo = (Bitmap) intent.getParcelableExtra("photoo"); image.setImageBitmap(photo); vinothp Try this, void saveImage() { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/saved_images"); String fname = "Image.jpg"; File file = new File (myDir, fname); if (file.exists ()) file.delete (); try { FileOutputStream out =

Can't create folder in extsd card

廉价感情. 提交于 2019-12-01 13:23:26
问题 I have an android tablet where external SD card called "/mnt/extsd" and its internal storage called "/mnt/sdcard". When I am try to create a folder in "/mnt/sdcard" by the following code. Application successfully creates folder in root directory, while I try to create folder in "/mnt/extsd" it toast an exception "open failed: EACCESS (Permission denied)" // create a File object for the parent directory File root_directory = new File("/mnt/extsd/abc/"); // have the object build the directory

To save the image in sdcard [closed]

喜你入骨 提交于 2019-12-01 13:05:14
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have Written the code for Editing the Image now I want to save that edited image in the sdcard image=(ImageView)findViewById(R.id.image); Intent intent = getIntent(); File sdCardDirectory = Environment

How can I check the app is movable to sd or not

北慕城南 提交于 2019-12-01 12:53:29
问题 I want to know how to check whether the app is movable to sd or not through code. I know how to get the installed applications list and is it on sd card or not. If ApplicationInfo flags contains ApplicationInfo.FLAG_EXTERNAL_STORAGE then it is on sd card but how can I check whether the app is movable to sd or not. 回答1: My first guess is too look into Android Source code for InstalledAppDetails activity. This is activity which shows "Move to phone" and "Move to SD card" buttons. It has