How to read the file and then save the image taken with the camera on Android
To read the file and then save the image captured by the camera on Android?
Previous How to save pictures taken with the camera function of the Android application is a continuation of.
This time, describes the procedures used to screen and display the data is actually reading was taken with the camera.
But they can not be taken much trouble, put on the screen because I do not mean ... is equal to.
I read more, and vary according to the method of saving either.
Save time, if the OutputStream to the file path saved in that way, what should I read using the InputStream.
This time, describes how to read the saved data using the "() MediaStore.Images.Media.insertImage".
I've struggled a little, should also be loaded with code like the following.
String [] proj = {
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.DISPLAY_NAME
;}
Cursor c = getContentResolver (). Query (
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
proj, null, null, null);
MediaStore.Images.Media.insertImage () is in the form of storing save data to a table dedicated to the media in the database of the terminal.
Therefore, when reading data, the procedure will be called to get the Cursor instance, etc. () method to query.
It is the same as when you get a call logs and bookmarks.
Makes use of the content provider.
Is the "proj" in the preceding sample code, and say with SQL, you specify a list of columns specified in the clause SELECT.
In the sample code above, has become an entity of data and implications, you will get the file name.
the first argument () method, you specify the "MediaStore.Images.Media.EXTERNAL_CONTENT_URI" indicating the area of external media media query.
This is also constant with time saved.
It will be in the sample code above, and pulling the image of the whole and, if necessary, you can also specify a condition.
So, let's also posted a continuation of this sample code.
if (c.moveToFirst ()) {
do {
Bitmap bitmap = BitmapFactory.decodeFile (c.getString (0));
String filename = c.getString (1);
/ / After is free to you!
} While (c.moveToNext ());
}
I'm sorry, not much sample code.
However, I think part of the reading of image data, and it pretty valuable information.
Would you think if I'm sorry, I do not think so.
The API reference, the contents of the data pointed to MediaStore.Images.Media.DATA is written only with the "DATA STREAM".
At first, I InputStream object Why? Is not thought, well was not available.
If you look, the file path is not actually come have been returned.
So, using () method to convert to Bitmap decodeFile of BitmapFactory class.
When was the file path,,, 's' s DATA STREAM of Ne Ne? Although I think I will ... What.
What the API reference for the Android, but do you feel like there is something a little sloppy. . .
As an aside, when you save (), I want us to save thumbnail images at the same time also MediaStore.Images.Media.insertImage the image.
The sample code in this time,
Although we have taken the image with the MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Thumbnails With the class, thumbnail images can be retrieved.
If you could also try the contents of my degree, to introduce, I would like to introduce.











