diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-02-29 14:02:06 -0800 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-02-29 14:06:36 -0800 |
commit | 8486bc11baa717390796f2ebd55c7b2ae9294bb7 (patch) | |
tree | 16e33a640cc642da10598e412c4834e40d9dda7c /cmds/content/src | |
parent | 6f9d697d8316f25be0e2a472604fd7e17d214c64 (diff) | |
download | frameworks_base-8486bc11baa717390796f2ebd55c7b2ae9294bb7.zip frameworks_base-8486bc11baa717390796f2ebd55c7b2ae9294bb7.tar.gz frameworks_base-8486bc11baa717390796f2ebd55c7b2ae9294bb7.tar.bz2 |
Update to allow passing empty string in a binding.
Change-Id: Ia16bd5dc78da1f5c8e52070d9c0e8431744224e8
Diffstat (limited to 'cmds/content/src')
-rw-r--r-- | cmds/content/src/com/android/commands/content/Content.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java index 1dcba70..bd9eb9a 100644 --- a/cmds/content/src/com/android/commands/content/Content.java +++ b/cmds/content/src/com/android/commands/content/Content.java @@ -69,6 +69,7 @@ public class Content { + " <COLUMN_NAME>:<TYPE>:<COLUMN_VALUE> where:\n" + " <TYPE> specifies data type such as:\n" + " b - boolean, s - string, i - integer, l - long, f - float, d - double\n" + + " Note: Omit the value for passing an empty string, e.g column:s:\n" + " Example:\n" + " # Add \"new_setting\" secure setting with value \"new_value\".\n" + " adb shell content insert --uri content://settings/secure --bind name:s:new_setting" @@ -245,13 +246,17 @@ public class Content { if (TextUtils.isEmpty(argument)) { throw new IllegalArgumentException("Binding not well formed: " + argument); } - String[] binding = argument.split(COLON); - if (binding.length != 3) { + final int firstColonIndex = argument.indexOf(COLON); + if (firstColonIndex < 0) { throw new IllegalArgumentException("Binding not well formed: " + argument); } - String column = binding[0]; - String type = binding[1]; - String value = binding[2]; + final int secondColonIndex = argument.indexOf(COLON, firstColonIndex + 1); + if (secondColonIndex < 0) { + throw new IllegalArgumentException("Binding not well formed: " + argument); + } + String column = argument.substring(0, firstColonIndex); + String type = argument.substring(firstColonIndex + 1, secondColonIndex); + String value = argument.substring(secondColonIndex + 1); if (TYPE_STRING.equals(type)) { values.put(column, value); } else if (TYPE_BOOLEAN.equalsIgnoreCase(type)) { |