Yeah that works perfectly, in my situation I'm working on an existing
project that is already in the wild, so I can't rely on a value in the
preferences file to check for this though. That would be the best
solution I think.

To get around this, I can do something like the following (going off
your original solution):

  File file = new File("/data/data/com.foo.bar/shared_prefs/
com.foo.bar_preferences.xml");
  if (file.exists()) {
    ...
  }

that is one big hard-coded string, but the existence of this file
seems to work ok. I guess it's alright?

Thanks


On Mar 18, 12:47 pm, Mark Murphy <[email protected]> wrote:
> Mark Wyszomierski wrote:
> > Yeah that definition is perfect, having a little trouble implementing
> > it though.
>
> > I'm just trying to use:
>
> >   File file = getFilesDir();
>
> > this points to:
>
> >   /data/data/com.foo.bar/files
>
> > which is empty though, nothing gets written there during my app's
> > lifetime. My app's directory structure looks like this:
>
> >   com/foo.bar
> >     /cache
> >     /databases
> >        webviewstuff.db
> >     /files
> >     /lib
> >     /shared_prefs
> >        com.foo.bar_preferences.xml
>
> > should I be seeing databases/preferences? Or am I supposed to be
> > looking for the existence of /shared_prefs/
> > com.foo.bar_preferences.xml. If so, is there a proper way to resolve
> > that path other than kind of hard-coding it into my app?
>
> If you have shared preferences, then you can do this:
>
> Step #1: Get your shared preferences (hopefully
> PreferenceManager.getDefaultSharedPreferences())
>
> Step #2: Look for the "hey! I've been run before" preference
>
> Step #2a: If that preference is not found, it's your first run, so set
> that preference (and commit() the change) and do your first-run logic
>
> Step #2b: If that preference is found, you've been run before,
> so...ummm...carry on, or whatever
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to