Emre Aktürk Emre Aktürk - 2 years ago 72
SQL Question

Get Cursor of given path

I have uri object that contains real path of an image. I know that we need to use selection string while query but i am bad at sql.

How can i get the cursor represent that image?

This is my projection string for my DTO.

String[] projection = {

And the Uri returns from cropping library.

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
final Uri resultUri = UCrop.getOutput(data);
} else if (resultCode == UCrop.RESULT_ERROR) {
final Throwable cropError = UCrop.getError(data);

Thanks for helps.

Answer Source

In general, a Uri does not have to represent a file on the filesystem, let alone have a path that you can determine, let alone be a file that you can access.

For a Uri whose scheme is file, getPath() returns the filesystem path to the file. However, you may not have read or write access to that file through the filesystem (though this would indicate a coding error on the part of whoever created the Uri and gave it to you).

For any other sort of Uri — the most common being those with a content scheme — there is no way to determine a filesystem path, because there is no requirement that the content be an ordinary file. It might be an encrypted file, content stored in a BLOB column in a database, content to be downloaded from the network, or countless other patterns.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download