mediastore

How to convert audio Mediastore Duration to minutes and seconds?

廉价感情. 提交于 2019-12-12 02:02:44
问题 I'm using the audio player tutorial from androidhive.info and in the SongsManager.java I'm trying to convert duration to minutes and seconds. I've managed to do it but I keep getting a NumberFormatException which I don't know how to deal with. Part of the code is here: public ArrayList<HashMap<String, String>> getPlayList(Context c) { String selectionMimeType = MediaStore.Files.FileColumns.MIME_TYPE + "=?"; /*use content provider to get beginning of database query that queries for all audio

What is difference between _ID and AUDIO_ID column?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 00:45:00
问题 I've googled it, searched on the official android docs, and found nothing satisfying. I'm developing music player app that has access to Media Storage and confused between _ID and AUDIO_ID. What are the differences between those two? (if any) 回答1: Following is difference. _ID The unique ID for a row. AUDIO_ID The ID of the audio file Difference _ID is column name of BASECOLUMNS database table. It is implemented in following other tables. Browser.BookmarkColumns, Browser.SearchColumns,

Android MediaStore get cursor position by comparing with TITLE_KEY

谁都会走 提交于 2019-12-11 22:53:31
问题 I am using MediaStore's media content and have a SearchView to filter the content displayed in a listfragment. I keep a reference to the cursor( mainCursor ) when the query string is null (which means all rows) When user searches, i get new cursor based on the query As per my understanding(I am very new to Cursor,DB & Contentprovider), the cursor will contain all the rows matching the query and the column to query is MediaStore.Audio.Media.TITLE , so i can see matching titles in list. public

Save and Insert video to gallery on Android 10

天大地大妈咪最大 提交于 2019-12-11 20:14:11
问题 I'm trying to save a video to the gallery,the following code works well an all Android versions except the Android Q : private void getPath() { String videoFileName = "video_" + System.currentTimeMillis() + ".mp4"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { ContentResolver resolver = getContentResolver(); ContentValues contentValues = new ContentValues(); contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, videoFileName); contentValues.put(MediaStore.MediaColumns.MIME_TYPE,

How to get all the audio file using mediastore

一曲冷凌霜 提交于 2019-12-11 13:33:55
问题 I am trying to get all the media files from the device (Internal and SDcard).Till now I am able to get all the media files from a fixed folder of SD Card .I have gone through most of the web pages on mediastore .And i am able to get the media info.But how can I get all the audio files from the device any example will be helpful. I tried this way ` public class SongDto { public long songId; public String songTitle; public String songArtist; public String path; public short genre; public long

WRITE_EXTERNAL_STORAGE permission is not required in AndroidQ with target API level 29, does it breaks security?

一笑奈何 提交于 2019-12-11 13:18:17
问题 I have stored image file into External Directory through Media store but it doesn't required permission for AndroidQ, even i have not mention permission in manifest. compileSdkVersion 29 defaultConfig { minSdkVersion 21 targetSdkVersion 29 } Note: Any application can store files on external storage without requesting permission to user, so is it break down security violation? 回答1: The argument, as I understand it, is that with MediaStore you are only supposed to be able to write to a few

Android Thumbnails inside MediaStore isn't getting refreshed after calling MediaScannerConnection.scanFile

╄→гoц情女王★ 提交于 2019-12-11 03:13:51
问题 I'm trying to build a Gallery-like app which will perform the following functions on External storage: List all the folder that has images inside it List all the images that available to the public (will not probe the files inside Android/data ) So far I can list all the images, and folders that have images. However, I later find that these images and folders are not the newest ones: they are not getting refreshed after I put some pictures (say I simply do some screenshots or download some

Getting Media Title from a File

依然范特西╮ 提交于 2019-12-11 01:39:07
问题 I used import java.io.File; to import all music files from my sdcard, Now i want the Title's of the files using Mediastore but how do I do that? This is the code I Use now. public class ListFiles extends ListActivity { private List<String> directoryEntries = new ArrayList<String>(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent i = getIntent(); File directory = new File(i.getStringExtra("directory")); if (directory.isDirectory()){ File[

Check if album art exists?

可紊 提交于 2019-12-11 00:25:12
问题 I'm building a music player app. I'm trying to populate a recyclerView with album arts of songs. I successfully did that with the code that is given below. But some of the songs do not have embedded album art not any album art in the folder. So, I'm trying to check if the album art is null or not before adding it to the recyclerView . If the album art is null, the app will automatically fetch it from the internet. I tried checking if the album art is null or not, but everytime it gives me a

Filter a managedQuery by file extension (or, alternatively, file type) for an Android Cursor

一个人想着一个人 提交于 2019-12-10 18:42:51
问题 I want to do a managedQuery using Android SDK where the results returned are filtered by their respective file extension (e.g. not the name, necessarily). I've done quite a bit of researching and am tired and hoping the community can help me.. I'm sure the answer is out there but, in lieu of reading an SQL book or whatever, I'm just trying to do something that should be pretty simple but not finding the solution. What I want to do is, essentially, something like: managedQuery(Audio.Media