android.os.Environment.getExternalStorageDirectory() Ludwig 2009/1/7 pradeep <pradeep...@gmail.com>
> > Your suggestion works:) Thanks for your reply. > could you please let me know how I can retrieve the path to SD card? > > On Jan 7, 1:22 pm, "Dianne Hackborn" <hack...@android.com> wrote: > > Er... this is not windows, you should use '/' as your path separator. > Also > > you really should retrieve the path to the sd card instead of hard-coding > > it. > > > > > > > > > > > > On Tue, Jan 6, 2009 at 11:16 PM, pradeep <pradeep...@gmail.com> wrote: > > > > > hi all, > > > > > the below program which i got form net. i am able to create the file > > > a.txt but the onEvent fuction is not being called as the Log.e > > > (........); is not getting logged. > > > > > plz help me out. > > > > > *************************************************************start of > > > the program******************************************************* > > > package com.home.files; > > > > > import java.io.File; > > > import java.io.IOException; > > > > > import android.app.Activity; > > > import android.os.Bundle; > > > import android.os.FileObserver; > > > import android.util.Log; > > > > > public class filesystem extends Activity > > > { > > > public static final String TAG="filesystem"; > > > public FileObserver observer; > > > @Override > > > public void onCreate(Bundle icicle) > > > { > > > super.onCreate(icicle); > > > setContentView(R.layout.main); > > > observer=new FileObserver("\\sdcard\\tmp"){ > > > @Override > > > public void onEvent(int event, String path) > > > { > > > Log.e(TAG,"onevent"); > > > if(event == FileObserver.CREATE){ > > > Log.e(TAG, "File created [" + > path + > > > "]"); > > > } > > > else if(event == FileObserver.DELETE){ > > > Log.e(TAG, "File deleted [" + > path + > > > "]"); > > > } > > > } > > > }; > > > observer.startWatching(); > > > File f=new File("\\sdcard\\tmp\\a.txt"); > > > > > try { > > > f.createNewFile(); > > > observer.stopWatching(); > > > Log.e(TAG,"file created"); > > > } > > > catch (IOException e) { } > > > > > } > > > } > > > > > **************************************End of the > > > > > > program****************************************************************************** > > > > > On Jan 6, 12:56 pm, "Dianne Hackborn" <hack...@android.com> wrote: > > > > Use android.os.FileObserver. > > > > > > On Mon, Jan 5, 2009 at 5:19 AM, pradeep <pradeep...@gmail.com> > wrote: > > > > > > > how to get notifications if i make any change in file system like i > > > > > add a file or delete a file. > > > > > > -- > > > > Dianne Hackborn > > > > Android framework engineer > > > > hack...@android.com > > > > > > Note: please don't send private questions to me, as I don't have time > to > > > > provide private support. All such questions should be posted on > public > > > > forums, where I and others can see and answer them. > > > > -- > > Dianne Hackborn > > Android framework engineer > > hack...@android.com > > > > Note: please don't send private questions to me, as I don't have time to > > provide private support. All such questions should be posted on public > > forums, where I and others can see and answer them.- Hide quoted text - > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---