• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic