grep -iqw "$rwords" "$sasfile" # No stout
echo $? # Prints 0, means grep succeeded
grep -iqw "word" "$sasfile" # No stout
echo $? # Prints 1, means grep failed
/ 登录 /
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case 1: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// got permission。
//在本地创建文件
File dir = new File(DOWNLOAD_PATH);
if (!dir.exists()) {
dir.mkdir();
Log.i("test", "start " + dir + "");
}
Log.i("test", dir.getName() + "");
File file = new File(dir, "KWMusic");
Log.i("test file", file.getName() + "");
PackageManager pm = getPackageManager();
Log.i("test PackageManagerInfo", pm.toString() );
final ProviderInfo info = pm
.resolveContentProvider(BuildConfig.APPLICATION_ID +".cindy", PackageManager.GET_META_DATA);
Log.i("test ProviderInfo", info.authority + "");
Uri imageUri= FileProvider.getUriForFile(this.getApplicationContext()
,BuildConfig.APPLICATION_ID +".cindy", file);//这里进行替换uri的获得方式
Log.i("test imageUri", imageUri + "");
try {
FileInputStream fis = new FileInputStream(file);
} catch (IOException E) {
E.printStackTrace();
Log.i("test", "文件没有创建");
}
} else {
// did not have permission
}
return;
}
}
}
答案 0 :(得分:0)
尝试替换您的代码
File dir = new File(DOWNLOAD_PATH);
if (!dir.exists()) {
dir.mkdir();
Log.i("test", "start " + dir + "");
}
使用
File dir = new File(DOWNLOAD_PATH);
if (!dir.exists()) {
dir.mkdir(); // Here is difference
Log.i("test", "start " + dir + "");
}