This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic