本文整理汇总了Java中android.content.ContentResolver.notifyChange方法的典型用法代码示例。如果您正苦于以下问题:Java ContentResolver.notifyChange方法的具体用法?Java ContentResolver.notifyChange怎么用?Java ContentResolver.notifyChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentResolver
的用法示例。
在下文中一共展示了ContentResolver.notifyChange方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyBatch
import android.content.ContentResolver; //导入方法依赖的package包/类
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
throws OperationApplicationException {
SQLiteDatabase db = mDbHolder.get();
db.beginTransaction();
ContentProviderResult[] result = null;
try {
result = super.applyBatch(operations);
db.setTransactionSuccessful();
ContentResolver res = mCr;
res.notifyChange(ScraperStore.ALL_CONTENT_URI, null);
return result;
} finally {
db.endTransaction();
}
}
示例2: onDeviceListUpdate
import android.content.ContentResolver; //导入方法依赖的package包/类
@Override
public void onDeviceListUpdate(List<Device> devices) {
final long now = System.currentTimeMillis() / 1000;
final ContentResolver cr = getContentResolver();
for(String deviceName : mUpnpId.keySet()){
boolean isInList = false;
for(Device device : devices){
if(deviceName.startsWith("upnp://" + device.hashCode())){
isInList = true;
break;
}
}
if (DBG) Log.d(TAG, "UPNP : is in list ? "+deviceName+ " "+String.valueOf(isInList));
long id = mUpnpId.get(deviceName).first;
updateServerDb(id, cr, mUpnpId.get(deviceName).second, isInList?1:0, now);
mUpnpId.put(deviceName, new Pair<>(id,isInList?1:0 ));
}
cr.notifyChange(NOTIFY_URI, null);
}
示例3: createUriAndNotify
import android.content.ContentResolver; //导入方法依赖的package包/类
/**
* returns that baseUri with appended Id and
* if not in an transaction calls notifyChange for the baseUri and any additional Uri
*/
private final static Uri createUriAndNotify(long rowId, SQLiteDatabase db,
Uri baseUri, ContentResolver cr, Uri... additionalNotifications) {
if (rowId < 0) return null;
Uri returnValue = ContentUris.withAppendedId(baseUri, rowId);
// only notify when not in an transaction
if (!db.inTransaction()) {
cr.notifyChange(baseUri, null);
if (additionalNotifications != null)
for (Uri additional : additionalNotifications)
cr.notifyChange(additional, null);
}
return returnValue;
}
示例4: updateDashClock
import android.content.ContentResolver; //导入方法依赖的package包/类
public static void updateDashClock(Context context) {
ContentResolver contentResolver = context.getContentResolver();
contentResolver.notifyChange(getUpdateUri(), null);
}
示例5: handleDb
import android.content.ContentResolver; //导入方法依赖的package包/类
protected static void handleDb(Context context, boolean hasLocalConnection) {
ContentResolver cr = context.getContentResolver();
if (hasLocalConnection) {
long now = System.currentTimeMillis() / 1000;
// list all servers in the db
Cursor c = cr.query(SERVER_URI, PROJECTION_SERVERS, SELECTION_SMB, null, null);
if (c != null) {
if (DBG) Log.d(TAG, "found " + c.getCount() + " servers");
while (c.moveToNext()) {
long id = c.getLong(COLUMN_ID);
String server = c.getString(COLUMN_DATA);
int active = c.getInt(COLUMN_ACTIVE);
MetaFile serverFile = MetaFile.from(server);
if (serverFile == null) {
Log.d(TAG, "bad server [" + server + "]");
continue;
}
if (serverFile.exists()) {
if (DBG) Log.d(TAG, "server exists: " + serverFile.getDisplayPath());
updateServerDb(id, cr, active, 1, now);
} else {
if (DBG) Log.d(TAG, "server does not exist: " + serverFile.getDisplayPath());
updateServerDb(id, cr, active, 0, now);
}
}
c.close();
// notify about a change in the db
cr.notifyChange(NOTIFY_URI, null);
} else if (DBG) {
Log.d(TAG, "server query returned NULL");
}
} else {
if (DBG) Log.d(TAG, "setting all smb servers inactive");
// no more smb servers.
ContentValues cv = new ContentValues(1);
cv.put(MusicStore.SmbServer.SmbServerColumns.ACTIVE, "0");
// update everything with inactive.
cr.update(SERVER_URI, cv, SELECTION_SMB, null);
// and tell the world
cr.notifyChange(NOTIFY_URI, null);
}
}
示例6: handleDb
import android.content.ContentResolver; //导入方法依赖的package包/类
protected void handleDb(Context context, boolean hasConnection, boolean hasLocalConnection) {
if(mUpnpId==null)
mUpnpId =new ConcurrentHashMap<>();
mUpnpId.clear();
final ContentResolver cr = context.getContentResolver();
Log.d(TAG, "hasConnection "+String.valueOf(hasConnection));
if (hasConnection) {
Lmhosts.reset();
final long now = System.currentTimeMillis() / 1000;
// list all servers in the db
Cursor c = cr.query(SERVER_URI, PROJECTION_SERVERS, SELECTION_ALL_NETWORK, null, null);
if (c != null) {
if (DBG) Log.d(TAG, "found " + c.getCount() + " servers");
while (c.moveToNext()) {
final long id = c.getLong(COLUMN_ID);
final String server = c.getString(COLUMN_DATA);
final int active = c.getInt(COLUMN_ACTIVE);
if(!server.startsWith("upnp")) {
final FileEditor serverFile = FileEditorFactoryWithUpnp.getFileEditorForUrl(Uri.parse(server+"/"), null);
if (serverFile == null) {
Log.d(TAG, "bad server [" + server + "]");
continue;
}
new Thread() {
@Override
public void run() {
if (serverFile.exists()) {
if (DBG)
Log.d(TAG, "server exists: " + server);
updateServerDb(id, cr, active, 1, now);
} else {
if (DBG)
Log.d(TAG, "server does not exist: " + server);
updateServerDb(id, cr, active, 0, now);
}
}
}.start();
}
else if(server.startsWith("upnp")){
mUpnpId.put(server,new Pair<>(id, active));
}
else
updateServerDb(id, cr, active, 1, now); //for distant folders, we don't check existence (for now)
}
if(mUpnpId.size()>0&&hasLocalConnection){
if(!mUpnpDiscoveryStarted) {
//we start upnp discovery but we don't want to add the listener twice
UpnpServiceManager.startServiceIfNeeded(context).addListener(this);
mUpnpDiscoveryStarted=true;
}
onDeviceListUpdate(new ArrayList<Device>(UpnpServiceManager.startServiceIfNeeded(context).getDevices()));
}
c.close();
// notify about a change in the db
cr.notifyChange(NOTIFY_URI, null);
} else if (DBG) {
Log.d(TAG, "server query returned NULL");
}
} else{
if (DBG) Log.d(TAG, "setting all smb servers inactive");
// no more smb servers.
ContentValues cv = new ContentValues(1);
cv.put(VideoStore.SmbServer.SmbServerColumns.ACTIVE, "0");
// update everything with inactive.
cr.update(SERVER_URI, cv, SELECTION_ALL_NETWORK, null);
// and tell the world
cr.notifyChange(NOTIFY_URI, null);
}
}
示例7: onMountedServerChange
import android.content.ContentResolver; //导入方法依赖的package包/类
@Override
public void onMountedServerChange() {
final Uri rootsUri = DocumentsContract.buildRootsUri(AUTHORITY);
final ContentResolver resolver = getContext().getContentResolver();
resolver.notifyChange(rootsUri, null, false);
}