If you think the Android project Locast-Core-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package edu.mit.mobile.android.locast.data;
/*//www.java2s.com
* Copyright (C) 2011 MIT Mobile Experience Lab
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import edu.mit.mobile.android.content.DBHelper;
import edu.mit.mobile.android.content.m2m.IdenticalChildFinder;
publicclass JSONSyncableIdenticalChildFinder implements IdenticalChildFinder {
@Override
public Uri getIdenticalChild(DBHelper m2m, Uri parentChildDir, SQLiteDatabase db, String childTable,
ContentValues values) {
Uri existingChild = null;
if (values.containsKey(JsonSyncableItem.COL_PUBLIC_URL)){
final Cursor existingItem = db.query(childTable, new String[]{JsonSyncableItem._ID, JsonSyncableItem.COL_PUBLIC_URL}, JsonSyncableItem.COL_PUBLIC_URL+"=?", new String[]{values.getAsString(JsonSyncableItem.COL_PUBLIC_URL)}, null, null, null);
if (existingItem.moveToFirst()){
existingChild = ContentUris.withAppendedId(parentChildDir, existingItem.getLong(existingItem.getColumnIndex(JsonSyncableItem._ID)));
}
existingItem.close();
}
return existingChild;
}
}