Content provider is an abstract data encapsulation and data access mechanism, such as SQLite is a data source with an Android device that can be encapsulated into a content provider. To read and write through the content provider, you need to use a URI. Recommended Read Android Learning Note (47): Content provider and Android contact information, Android learning Note (48): Provide your own content Provider and Android Learning notes (49): Access data via content provider. Content provider's imp
Mediastore is the Android system comes with the multimedia system database, he is refreshed at each boot, you can use the cursor this class to access and modify the database, modified after the need for broadcast forced refresh.Use the cursor to obtain an object instance of Contentresolver through the context.Cursor Cursor1 = Context.getcontentresolver (). Query (MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,null, null,null,null);View CodeThe context in
protectedvoidonActivityResult(intint resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); }In the Onactivityresult method, the data parameter is used to obtain the image:/** * 通过data取得图片 */Bundle extras = data.getExtras();Bitmap bitmap = (Bitmap) extras.get("data");mImageViewShow.setImageBitmap(bitmap);However, now the cell phone pixel so high, if the picture is particularly large, will the data too large and FC it? Rest assured, Android has long been t
Today, I have been struggling for a long time. I use the Android api:[Java]Bitmap bitmap = imageMap. get (url );MediaStore. Images. Media. insertImage (getContentResolver (), bitmap, "myPhoto ","");Save the bitmap to the system album. The saved image cannot be found until the album is opened. However, after restarting the phone, you can find it in the album. After the study, we found that you need to refresh the album environment to the album after wr
(IOException e) {//Todo Auto-gene Rated catch Blocke.printstacktrace ();} Recorder.start (); Stateview.settext ("recording"); btnstart.setenabled (false); btnplay.setenabled (false); Btnstop.setenabled (true); Break;case r.id.btn_stop:recorder.stop (); Recorder.release ();// We can then store our recording files in Mediastore contentvalues values = new Contentvalues (); Values.put (MediaStore.Audio.Media.TITLE, " This is my first Record-audio "); Val
1. click the button, specify the action and uri, and set the result code (ResultCode) to reach the Gallery of the default album on the mobile phone.
The Code is as follows:1. public void onClick (View v ){2. // TODO Auto-generated method stub3. Intent intent = new Intent (Intent. ACTION_PICK,4. android. provider. MediaStore. Images. Media. EXTERNAL_CONTENT_URI); // start the Photo Gallery5. startActivityForResult (intent, 0 );6 .}2. Select an image a
1. click the button, specify the action and uri, and set the result code (ResultCode) to reach the Gallery of the default album on the mobile phone.
The Code is as follows:1. public void onClick (View v ){2. // TODO Auto-generated method stub3. Intent intent = new Intent (Intent. ACTION_PICK,4. android. provider. MediaStore. Images. Media. EXTERNAL_CONTENT_URI); // start the Photo Gallery5. startActivityForResult (intent, 0 );6 .}2. Select an image a
, Uri. fromFile () is used to create A file: // style Uri object for the shared Intent object.
C. images, videos, and audios can be scanned and added to a multimedia file in the system media store. You can use scanFile () to check whether the file exists. onScanCompleted () the callback method returns a Uri object used to share the content: // style contained in the Intent object.
D. the insertImage () method can be used to insert an image to the MediaStore
);
Uri uri = Uri. parse ("file: // sdcard/song.mp3 ");
It. setDataAndType (uri, "audio/mp3 ");
StartActivity (it );
Uri uri = Uri. withAppendedPath (MediaStore. Audio. Media. INTERNAL_CONTENT_URI, "1 ");
Intent it = new Intent (Intent. ACTION_VIEW, uri );
StartActivity (
Mediastore functionality is the file type ContentProvider. The underlying data of ContentProvider looks like a sqlite database, but ContentProvider does not have any requirements for the underlying data storage, you can use the SQLite database, or you can use normal files. You can even use an object in memory to store data. To observe the data changes in a contentprovider, you can register the observer through the Contentresolver Registercontentobser
"}; String [] ccs = {"you@abc.com"}; it. putExtra (Intent. EXTRA_EMAIL, tos); it. putExtra (Intent. EXTRA_CC, ccs); it. putExtra (Intent. EXTRA_TEXT, "The email body text"); it. putExtra (Intent. EXTRA_SUBJECT, "The email subject text"); it. setTy Pe ("message/rfc822"); startActivity (Intent. createChooser (it, "Choose Email Client"); Intent it = new Intent (Intent. ACTION_SEND); it. putExtra (Intent. EXTRA_SUBJECT, "The email subject text"); it. putExtra (Intent. EXTRA_STREAM, "file: // sdcard/
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.