Java tutorial
//package com.java2s; // Licensed under the Apache License, Version 2.0 import java.util.ArrayList; import java.util.HashMap; import android.content.ContentValues; import android.net.Uri; public class Main { public static void shiftTableUriIds(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, String authority, String path, long topTableId) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return; } for (ContentValues restoreCv : restoreOperations) { if (restoreCv.containsKey(idColumnName) && null != restoreCv.getAsString(idColumnName)) { Uri uri = Uri.parse(restoreCv.getAsString(idColumnName)); if ("content".equalsIgnoreCase(uri.getScheme()) && authority.equals(uri.getAuthority()) && uri.getPath().substring(0, uri.getPath().lastIndexOf('/')).equals(path)) { Uri.Builder newUri = uri.buildUpon() .path(uri.getPath().substring(0, uri.getPath().lastIndexOf('/'))) .appendPath(String.valueOf( Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1)) + topTableId)); // Log.v("URI", uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)); // Log.v("URI", String.valueOf(Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)) + topTableId)); restoreCv.put(idColumnName, newUri.build().toString()); } } } } }