use of android.database.Cursor in project jpHolo by teusink.
the class FileHelper method getRealPath.
/**
* Returns the real path of the given URI string.
* If the given URI string represents a content:// URI, the real path is retrieved from the media store.
*
* @param uriString the URI string of the audio/image/video
* @param cordova the current application context
* @return the full path to the file
*/
@SuppressWarnings("deprecation")
public static String getRealPath(String uriString, CordovaInterface cordova) {
String realPath = null;
if (uriString.startsWith("content://")) {
String[] proj = { _DATA };
Cursor cursor = cordova.getActivity().managedQuery(Uri.parse(uriString), proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(_DATA);
cursor.moveToFirst();
realPath = cursor.getString(column_index);
if (realPath == null) {
LOG.e(LOG_TAG, "Could get real path for URI string %s", uriString);
}
} else if (uriString.startsWith("file://")) {
realPath = uriString.substring(7);
if (realPath.startsWith("/android_asset/")) {
LOG.e(LOG_TAG, "Cannot get real path for URI string %s because it is a file:///android_asset/ URI.", uriString);
realPath = null;
}
} else {
realPath = uriString;
}
return realPath;
}
use of android.database.Cursor in project cordova-android-chromeview by thedracle.
the class FileHelper method getRealPath.
/**
* Returns the real path of the given URI string.
* If the given URI string represents a content:// URI, the real path is retrieved from the media store.
*
* @param uriString the URI string of the audio/image/video
* @param cordova the current application context
* @return the full path to the file
*/
@SuppressWarnings("deprecation")
public static String getRealPath(String uriString, CordovaInterface cordova) {
String realPath = null;
if (uriString.startsWith("content://")) {
String[] proj = { _DATA };
Cursor cursor = cordova.getActivity().managedQuery(Uri.parse(uriString), proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(_DATA);
cursor.moveToFirst();
realPath = cursor.getString(column_index);
if (realPath == null) {
LOG.e(LOG_TAG, "Could get real path for URI string %s", uriString);
}
} else if (uriString.startsWith("file://")) {
realPath = uriString.substring(7);
if (realPath.startsWith("/android_asset/")) {
LOG.e(LOG_TAG, "Cannot get real path for URI string %s because it is a file:///android_asset/ URI.", uriString);
realPath = null;
}
} else {
realPath = uriString;
}
return realPath;
}
use of android.database.Cursor in project cordova-android-chromeview by thedracle.
the class ContactAccessorSdk5 method remove.
@Override
public /**
* This method will remove a Contact from the database based on ID.
* @param id the unique ID of the contact to remove
*/
boolean remove(String id) {
int result = 0;
Cursor cursor = mApp.getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.Contacts._ID + " = ?", new String[] { id }, null);
if (cursor.getCount() == 1) {
cursor.moveToFirst();
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
result = mApp.getActivity().getContentResolver().delete(uri, null, null);
} else {
Log.d(LOG_TAG, "Could not find contact with ID");
}
return (result > 0) ? true : false;
}
use of android.database.Cursor in project glimmr by brk3.
the class LocalPhotosGridFragment method initGridView.
@Override
protected void initGridView() {
mGridView = (GridView) mLayout.findViewById(R.id.gridview);
mGridView.setVisibility(View.VISIBLE);
mGridView.setMultiChoiceModeListener(this);
mShowDetailsOverlay = false;
String[] from = { MediaStore.MediaColumns.TITLE };
int[] to = { android.R.id.text1 };
CursorLoader cursorLoader = new CursorLoader(getActivity(), SOURCE_URI, null, null, null, MediaStore.Audio.Media.TITLE);
Cursor cursor = cursorLoader.loadInBackground();
mAdapter = new MediaStoreImagesAdapter(getActivity(), R.layout.gridview_item, cursor, from, to);
mGridView.setAdapter(mAdapter);
mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL);
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
final String usageTip = getString(R.string.upload_photos_tip);
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
UsageTips.getInstance().show(mActivity, usageTip, true);
}
});
}
use of android.database.Cursor in project FileDownloaderManager by arlyxiao.
the class SystemDownloadActivity method update_progress.
public void update_progress() {
int[] bytes_and_status = new int[] { -1, -1, 0 };
DownloadManager.Query query = new DownloadManager.Query().setFilterById(download_id);
Cursor c = null;
try {
c = downloadmanager.query(query);
if (c != null && c.moveToFirst()) {
bytes_and_status[0] = c.getInt(c.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));
Log.i("到目前为止下载的大小 ", Integer.toString(bytes_and_status[0]));
bytes_and_status[1] = c.getInt(c.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES));
Log.i("总大小 ", Integer.toString(bytes_and_status[0]));
bytes_and_status[2] = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
Log.i("下载状态 ", Integer.toString(bytes_and_status[0]));
}
} finally {
if (c != null) {
c.close();
}
}
handler.sendMessage(handler.obtainMessage(0, bytes_and_status[0], bytes_and_status[1], bytes_and_status[2]));
}
Aggregations