android-contentresolver

Using ContentResolver and Regex to get music from specific folder

萝らか妹 提交于 2019-12-14 04:26:02
问题 I am currently trying to retrieve music files within a specific folder from the ContentResolver . I only want the files in that folder, not from a subfolder. I achieved to get these files by doing this: String pattern = f.getAbsolutePath() + "/[^/]*"; // f is the folder where I want to search ArrayList<TrackInfo> retVal = new ArrayList<TrackInfo>(); Cursor mCursor = null; String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0 AND " + DATA + " LIKE '" + f.getAbsolutePath() + "/%'"; Uri

Creating & using ContentProvider for android

拟墨画扇 提交于 2019-12-14 03:53:01
问题 When I call an Android ContentProvider I get the following exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{de.harm.android.couchone/de.harm.android.couchone.CouchContactClient}: java.lang.IllegalArgumentException: Unknown URL content://de.harm.android.couchone.provider/test2 These are the projects: https://github.com/der-harm/CouchOneProvider .../CouchOneContacts Android uses the so-called ContentResolver to communicate with ContentProvider which in turn handles

How to listen new photos in android?

Deadly 提交于 2019-12-13 11:48:31
问题 I need to listen to new images that comes from any source like downloading images, capture new images, other apps download images..etc Is there any listener that will trigger event whenever new photos is added to gallery? I have been searching for two days. I could not get anything solid. I read about FileObserver , will that help? 回答1: new photos arrives to gallery means it has been added to the MediaStore . First of all, FileOberver is a memory-killer approach. Consider a high volume of

ContentResolver in android 2.2 [issue]

筅森魡賤 提交于 2019-12-13 05:40:57
问题 Am trying to insert an aduio file in the android phone. the same code works fin in android 2.1 but when i try to use it in Android 2.2; the inserting in ContentResolver succseed but i can't find my audio file in the gallery (so the user can't see it) context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename))); File k = new File(path, filename); ContentValues values = new ContentValues(); values.put(MediaStore.Audio.Media.DATA, k.getAbsolutePath

Getting RadioButton cannot be resolved to a type

一世执手 提交于 2019-12-13 04:22:28
问题 I am trying to build a radio button input activity. I have done whatever described in http://developer.android.com/guide/topics/ui/controls/radiobutton.html But I am getting "RadioButton cannot be resolved to a type" error in boolean checked = ((RadioButton) view).isChecked(); line. I am getting Red line under "((RadioButton) view)" part. What I am missing? Please help. package com.my.test; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android

Getting the recent images from gallery from cursor using ContentResolver

邮差的信 提交于 2019-12-13 02:33:14
问题 I'm using Cursor to get the images from gallery and getting all the images from gallery, is there any way to get only few recent images, such as last 20 image captured. One more problem, I am facing is the images are coming from older to new order, I want to get the image in reverse order(new to older). final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID }; final String orderBy = MediaStore.Images.Media._ID; My code to get image: public void getImg(){ Cursor

CursorLoader notify data change

混江龙づ霸主 提交于 2019-12-13 01:29:27
问题 I've implemented my custom ContentProvider and it has several URI s: The main one: //Return all items, uriType = ALLITEMS String BASEURI = "content://authority/items" and //Return all items in category #, uriType = ITEMS "content://authority/items/cat/#" //Return all items in category # starting with *, uriType = ITEMS_INITIAL "content://authority/items/cat/#/*" My Activity implements these Loader callbacks: @Override public Loader<Cursor> onCreateLoader(int id, Bundle arg1) { CursorLoader

How to Read Pen Drives connected through OTG?

为君一笑 提交于 2019-12-12 20:19:37
问题 Here is my code of my activity. public class MainActivity extends AppCompatActivity { ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lv=findViewById(R.id.chckExternal); filter(); } this is my code of filter files... //--------------------Filter files---------------- public ArrayList<File> findSongs(File root) { ArrayList<File> al = new ArrayList<>(); for(File singleFile : root.listFiles())

RuntimeException at CallLog.Calls

这一生的挚爱 提交于 2019-12-12 19:20:09
问题 I get sometimes on some devices an RuntimeException, if I try to query the CallLog.Calls . I query the CallLog.Calls with contentProvider to get the last call. Can anybody help why am I getting this error sometimes? I think, this is a system bug/problem? Caused by: android.database.sqlite.SQLiteException: no such column: sdn_alpha_id: , while compiling: SELECT sns_receiver_count, numberlabel, service_type, matched_number, type, contactid, lookup_uri, mime_type, sdn_alpha_id, sp_type,

Using mp4parser , how can I handle videos that are taken from Uri and ContentResolver?

你离开我真会死。 提交于 2019-12-12 07:25:42
问题 Background We want to let the user choose a video from any app, and then trim a video to be of max of 5 seconds. The problem For getting a Uri to be selected, we got it working fine (solution available here) . As for the trimming itself, we couldn't find any good library that has permissive license, except for one called "k4l-video-trimmer" . The library "FFmpeg", for example, is considered not permission as it uses GPLv3, which requires the app that uses it to also be open sourced. Besides,