android-sdcard

Android Studio music player cant read from sdcard, only internal memory

北慕城南 提交于 2020-01-01 06:34:25
问题 I apologize if this turns out to be a stupid question, it might turn out as a quick fix but I just cant figure it out. I'm building a music player in android studio and none of the songs on the sdcard dont show up in the list view, only the ones in internal memory, even though I did implement getExternalStorageDirectory() and added the permission in the manifest file. Any input on this or constructive criticism is greatly apreciated. Here is the main java class. public class MainActivity

Android get id of SD Card programmatically

大兔子大兔子 提交于 2019-12-31 04:27:07
问题 Is there any way which I can get some specific identifier/serial number of current SD Card in Android devices programmatically? 回答1: Yes, try this: public String getSDCARDiD() { String sd_cid = null; try { File file = new File("/sys/block/mmcblk1"); String memBlk; if (file.exists() && file.isDirectory()) { memBlk = "mmcblk1"; } else { //System.out.println("not a directory"); memBlk = "mmcblk0"; } Process cmd = Runtime.getRuntime().exec("cat /sys/block/"+memBlk+"/device/cid"); BufferedReader

Android backup and restore database to and from SD-card

依然范特西╮ 提交于 2019-12-30 05:03:45
问题 I'm currently looking to build a backup feature in my Android application. However I'm kinda struggling before even starting to implement it because I'm not sure what the correct way to go is. I found some interesting articles on the net and so I came up with three possible solutions: Backup the entire DB file to the SD card Export the DB-data to an XML file on the SD card Use the Android backup mechanism to backup the entire DB to the Google cloud Now I was wondering what you guys think

Android backup and restore database to and from SD-card

时光怂恿深爱的人放手 提交于 2019-12-30 05:03:02
问题 I'm currently looking to build a backup feature in my Android application. However I'm kinda struggling before even starting to implement it because I'm not sure what the correct way to go is. I found some interesting articles on the net and so I came up with three possible solutions: Backup the entire DB file to the SD card Export the DB-data to an XML file on the SD card Use the Android backup mechanism to backup the entire DB to the Google cloud Now I was wondering what you guys think

Displaying images from specific folder in sd card in grid view

夙愿已清 提交于 2019-12-29 07:17:09
问题 I had developed an application in which I have to display images from specific folder in sd card. My code is working fine but it is showing all images that are sd card. I had given selection args as my folder's name as it has been metioned the following post: Displaying images from a specific folder on the SDCard using a gridview But, it didn't worked. Please, suggest me how to do this: Below I am posting my code. public class Album1Activity extends Activity { static Cursor imageCursor;

How to check if a SD Card has been inserted to the tablet or not : Android?

[亡魂溺海] 提交于 2019-12-29 06:30:32
问题 I am working on a simple app, which should be able to access files from internal storage and as well as from external storage (Removable cards) like Micro SD cards (when an user inserts a SDCARD). (Not the internal sdcard which comes with the device, I know it can be accessed using Environment.getExternalStorageDirectory() ) Is it possible to find out if an user has inserted a sdcard to the device? If yes, Is it possible to get the path of that SD CARD? I found that hard coding the path was

How To Add Media To MediaStore on Android 4.4 KitKat SD Card With Metadata

我只是一个虾纸丫 提交于 2019-12-29 04:24:32
问题 Background: In Android 4.4, Google decided that apps should not have write access to SD cards. However, apps can write to /SDCard/Android/data/App Package Name. So this is what I've done. I have written an MP3 file to /Android/data/. I then want this MP3 file to show up in Android music players. I've tried the following... sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + filePath))); and.... MediaScannerConnection.scanFile(this, new String[] { file.toString() }, new

Getting all the total and available space on Android

余生颓废 提交于 2019-12-28 02:07:31
问题 To my knowledge, on Android, there is: Internal memory for apps and cache Internal SD Card on some phones (not removable) External SD Card for music and photos (removable) How do I get the total and available for each with a check that they exist (some phones do not have an internal SD Card) Thanks 回答1: Here is how you get internal storage sizes: StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long blockSize = statFs.getBlockSize(); long totalSize = statFs

how to list images on sd card sorted according to time

我的未来我决定 提交于 2019-12-25 13:17:26
问题 I can get the list of images in sd card using fololowing` but these are not sorted how can I get them sorted either by name or time thanks in advance String ExternalStorageDirectoryPath = Environment .getExternalStorageDirectory().getAbsolutePath(); String targetPath = ExternalStorageDirectoryPath + "/somedirectoryname/"; File targetDirectory = new File(targetPath); File[] files = targetDirectory.listFiles();` for (File file : files1) { list.add(file.getAbsolutePath().toString()); } 回答1:

how to list images on sd card sorted according to time

谁说我不能喝 提交于 2019-12-25 13:17:22
问题 I can get the list of images in sd card using fololowing` but these are not sorted how can I get them sorted either by name or time thanks in advance String ExternalStorageDirectoryPath = Environment .getExternalStorageDirectory().getAbsolutePath(); String targetPath = ExternalStorageDirectoryPath + "/somedirectoryname/"; File targetDirectory = new File(targetPath); File[] files = targetDirectory.listFiles();` for (File file : files1) { list.add(file.getAbsolutePath().toString()); } 回答1: