File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes How to find out programatically that file is already exist or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to find out programatically that file is already exist or not?" Watch "How to find out programatically that file is already exist or not?" New topic
Author

How to find out programatically that file is already exist or not?

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello everybody,

Actually I am developing one application in that when application run
first time it will create one txt file and save IMSI number in that
file. when mobile boot it will matches it's current IMSI number with
IMSI number present in the txt file.But I don't know how to check programatically that
file is exist or not.
Please help me
Thanks



Life is easy because we write the source code.....
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

You need to read up on Java File IO; creating and writing to files on Android is similar to what we do in Java (save for some extra settings like permissions).

java.io.File class is an abstraction for a file or directory on a System. And you can use its interface to do lots of stuff including questioning existence of a File. For details of what interface the class provides, you need to read the documentation.

For instance, if you want to check if a file named "temp.txt" exists on my sdcard, create a File object representing this file and call exists() method.


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello everybody again,

I am developing one application that will create one txt file when it runs first time and saves IMSI number in that file , After that when phone boots every time it checks that IMSI number with IMSI number which is stored at txt file. But when I run this program it gives me Null pointer Exception. I have following code.


//FinalSMS.java


###############################################################

//MyStartupIntentReceiver .java


################################################################################


//AndroidManifest.java

#################################################################################

But when I run it it gives me following error messages


######################################################

when I had checked whether the file is created or not in data/data/com/micro/files/ The file is not present.
Because file is not created therefore it throws run time exception (NullPointerException) , Please help me

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find out programatically that file is already exist or not?