Monday, July 4, 2011

Securing the app 2 - Hiding the multimedia files

One of the issues with distributing multimedia files is that they can be easily copied. These are professional audio files, and first off, I'm looking for a way to prevent them from showing up in peoples music players for one thing.

First things first - I need to make sure the files are getting deleted when the app get's uninstalled. Right now, I don't believe they are.

I read something about how if it was for API level 8, it would do that. How do I find out what the API level I'm at is?

Here's someting:

http://stackoverflow.com/questions/2944074/eclipse-android-change-api-level

Well, I found I've been using a couple of things that were ahead of my time, when I change the target to level 8 from a higher one for android 3.0. The Normalize was an import statement, but this one:

android:overScrollMode="always", but I believe it's a level 3. I totally forget what it means. I'm sure I put it there for a reason. However, I can't shut out 2.2 users! So I need to go back to targeting at least that level (8)

Ok, the problem may by that I'm loading the files from a server instead of resources. Would android keep charge of file that you've downloaded as opposed to created from resources?

Ok, let's let that one go. But, what I can hopefully do is prevent them from showing up in the filesystem by prefixing a "." in front of the file name. So, when I do that, it still appears in Astro. but not in adb shell. So that's something.



Actually, getting back to the previous issue, SO points out this link:

http://androinica.com/2009/08/how-to-hide-non-music-audio-files-from-appearing-in-android-media-players/

Saving cache files

If you're using API Level 8 or greater, use getExternalCacheDir() to open a File that represents the external storage directory where you should save cache files. If the user uninstalls your application, these files will be automatically deleted. However, during the life of your application, you should manage these cache files and remove those that aren't needed in order to preserve file space.

If you're using API Level 7 or lower, use getExternalStorageDirectory() to open a File that represents the root of the external storage, then write your cache data in the following directory:

/Android/data//cache/
The is your Java-style package name, such as "com.example.android.app".

Actually, I am using 8. So according to this, all I have to do is change from getExternalStorageDirectory() to getExternalCacheDir().

Let's uninstall and try it.

Allright - the particular function needed a activity/context, so I had to make sure that wherever it's called had one available. So, now it's download the data...hmm, I didn't really delete it. Well, I guess it's ok if it's deleting the data. But the other possibility is it's in a different location. I'll have to check and make sure it loads, and I'll have to check and make sure it doesn't redownload it twice.

Hmmm...no luck. Ok, ready to dump it and move on. At least, it doesn't seem to mixing with the music file app, and you can't get at it with adb shell, although the files are visible from Astro.

Ok. That's a wrap. Next step is licensing.

No comments:

Post a Comment