In ubuntu, isFile() and isDirectory() don’t work perfectly. I used this code to find out if something is a file or directory:
boolean fileName= file.getName().lastIndexOf('.') == -1;
But the problem is that I made a folder named bhargav.panchal. With the above function, this folder is considered as a file, not a folder.
File file=new File("/home/asd/My_Shared_File/bhargav.panchal");
if(file.exists()){
if(!file.isDirectory()) {
Toast.makeText(activity, "This is File", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(activity, "This is Directory", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(activity, "File or Directory doesn't exist.", Toast.LENGTH_SHORT).show();
}
In this condition, the isDirectory() and isFile() methods always return false.
No, you are wrong somewhere. On the contrary you cant access external environment with DVM.
reason : it is not possible for applications to interfere with each other based on the OS level
security and Dalvik VMs are confined to a single OS process, Dalvik itself is not concerned with
runtime security. Although Dalvik is not relied upon for security, it is interesting to note that most
of the standard Java security classes remain in the Android distribution. These include the
java.lang.SecurityManager and some of the classes in the java.security package. In standard Java
environments, the SecurityManger plays the role analogous to the OS process-level security in
Android. The SecurityManager typically controls access to resources external to the JVM such as
files, processes, and the network. In the Android distribution, the standard security framework is
apparently present for applications to use within their
own application spacebut is neither fullyimplemented nor configured (no java.policy files are present) for interprocess security.