Hi David, In the following, I demonstrate how to use the External media, for your "internal storage" request, might I suggest you simply use the terminal and type the following to find your mount points as a point of reference.
mount That wasn't difficult now ;-) - what everybody who works with Android should realise, the file system security comes with specific limitations. For this reason, the external SDCard typically ALWAYS contains the following logical directory - /android/data - so if your SDcard mount point is /mnt/sdcard/ - your absolute path will be - /mnt/sdcard/android/data/com.your.app.name - from here, you can extract in R+W and set files, which may require you to mount the system in R+W mode, depending on your requirements. http://developer.android.com/guide/topics/data/data-storage.html SDCard is always R+W so this is a nice place to write to and be certain your package is extracted. From here, you know where you stand and can enumerate from this point if you like, in preference of the Internal Storage.. you should be aware of that by default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed. To create and write a private file to the internal storage: 1. Call openFileOutput()<http://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String, int)> with the name of the file and the operating mode. This returns a FileOutputStream<http://developer.android.com/reference/java/io/FileOutputStream.html> . 2. Write to the file with write()<http://developer.android.com/reference/java/io/FileOutputStream.html#write(byte[])> . 3. Close the stream with close()<http://developer.android.com/reference/java/io/FileOutputStream.html#close()> . For example: String FILENAME = "hello_file"; String string = "hello world!"; FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); fos.write(string.getBytes()); fos.close(); As I was saying, you may find in many cases the requirement for External storage. Here I present to you something that I have used in commercial applications with brevity for omitted methods, I am certain that this will suffice to suit your purpose in Android 1.6 to 2.3.4. Enjoy! private void extractInstaller() throws IOException { // Path to write to String path = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/Android/data/com.your.app.media/"; // Current state of the external media String extState = Environment.getExternalStorageState(); // External media must be written onto if (extState.equals(Environment.MEDIA_MOUNTED)) { try { // Ensure path exists boolean exists = (new File(path)).exists(); if (!exists) { new File(path).mkdirs(); } InputStream data = getResources().getAssets().open("installer"); /** EXTRACTION METHOD **/ writeInstaller(path, data); /** EXTRACTION METHOD **/ } catch (Exception ioe) { ioe.printStackTrace(); } } else { Log.e(getPackageName(), "not mounted?"); } } Best Regards, Glen On Fri, May 27, 2011 at 10:21 PM, david.chhang <[email protected]>wrote: > Isn't it the path for an external storage ? Here, I want to know the path > for > the files in the internal storage. > > -- > View this message in context: > http://mono-for-android.1047100.n5.nabble.com/Know-if-a-file-already-exists-in-the-internal-storage-tp4428476p4431703.html > Sent from the Mono for Android mailing list archive at Nabble.com. > _______________________________________________ > Monodroid mailing list > [email protected] > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid > -- Glen Hassell Inner Technique http://innertech.com.au/ Office: 03 9687 0006 Mobile: +61 (0) 438 340 385
_______________________________________________ Monodroid mailing list [email protected] UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
