gpt4 book ai didi

android - switch 语句后无法访问的代码

转载 作者:太空狗 更新时间:2023-10-29 16:42:08 27 4
gpt4 key购买 nike

public Cursor query(Uri paramUri, String[] paramArrayOfString1, String paramString1,String[] paramArrayOfString2, String paramString2)
{
SQLiteQueryBuilder localSQLiteQueryBuilder = new SQLiteQueryBuilder();
if (paramUri.getPathSegments().size() == 1);
for (StringBuilder localStringBuilder = null; ; localStringBuilder = new StringBuilder(100))
switch (sURIMatcher.match(paramUri))
{
case 0:

case 1:

case 2:

case 3:
default:
throw new IllegalArgumentException("Unknown URI " + paramUri);
}
localSQLiteQueryBuilder.setTables("category");//unreachable code


while (true)
{
Cursor localCursor = localSQLiteQueryBuilder.query(mOpenHelper.getReadableDatabase(), paramArrayOfString1, paramString1, paramArrayOfString2, null, null, paramString2);
localCursor.setNotificationUri(contentResolver, paramUri);
return localCursor;
localSQLiteQueryBuilder.setTables("shop,category");
localSQLiteQueryBuilder.appendWhere("shop_category_id=category._id");
continue;
localSQLiteQueryBuilder.setTables("shop,category");
StringBuilder localStringBuilder;
localStringBuilder.append("shop_category_id=category._id");
localStringBuilder.append(" AND ");
localStringBuilder.append("_id");
localStringBuilder.append('=');
localStringBuilder.append((String)paramUri.getPathSegments().get(1));
localSQLiteQueryBuilder.appendWhere(localStringBuilder.toString());
continue;
localSQLiteQueryBuilder.setTables("shop,category");
localSQLiteQueryBuilder.setDistinct(true);
localStringBuilder.append("shop_category_id=category._id");
localStringBuilder.append(" AND ");
localStringBuilder.append("shop_category_id");
localStringBuilder.append('=');
localStringBuilder.append((String)paramUri.getPathSegments().get(1));
localSQLiteQueryBuilder.appendWhere(localStringBuilder.toString());
paramString2 = "shop._id";
}
}

我在 switch 语句后遇到无法访问的代码错误,我不知道如何解决它。我试图删除该行,但如果我这样做,我会遇到很多错误。我的代码在上面。任何人都可以帮助我?提前致谢。

最佳答案

代码确实无法访问:

所有情况都是失败的(它们没有 break 语句,所以匹配后的所有情况都会执行)并以抛出 default 的情况结束 异常。这意味着抛出 Exception 之后的代码将永远不会被执行。

也许你的意思是这样的:

 switch (sURIMatcher.match(paramUri)){
case 0:
// do something
break;
case 1:
// do something
break;
case 2:
// do something
break;
case 3:
// do something
break;
default:
throw new IllegalArgumentException("Unknown URI " + paramUri);
}

关于android - switch 语句后无法访问的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15991613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com