Reputation: 57
Hi when I do File file = new File(tempPath)
app is crashing when tempPath
is empty
File file = new File(tempPath);
if (!file.isFile());
Upvotes: 0
Views: 133
Reputation: 157467
Because it accessing a invalid location on the hard memory of the device. If you are fortunate he will try to access "/"
. To avoid this you should check if tempPath
is empty this way:
if (TextUtils.isEmpty(tempPath)) {
}
isEmpty
will return true both it the string is empty or null
Upvotes: 1