0

I have ported a C shared library to Android using SWIG and the Android-NDK

In order to test some my library API I need to be able to specify files, e.g. to load data from

I am currently doing all my development using an emulator (I don't have a smartphone) and am wondering how I can:

a) move files on to the emulator (possibly adb shell mv?)

b) access those files from my Java code

any pointers gratefully received

bph
  • 10,728
  • 15
  • 60
  • 135

1 Answers1

1

If you want to have the files within your application, you can put them in the assets/ folder of the root directory of your project (create it if it doesn't exist).

From there you can access them with the AssetManager class

http://developer.android.com/reference/android/content/res/AssetManager.html

You can use the SD card as well, here is explained how to get files onto the enulators SD card

Manually put files to Android emulator SD card

Here is the documentation on how to access the data afterwards

http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

Community
  • 1
  • 1
Hans Hohenfeld
  • 1,729
  • 11
  • 14
  • is there an approach where the files can exist outside the application? e.g. an area in the android emulator FS where you can copy files to and open them from your app java code? (or would that be some security issue) – bph Aug 03 '12 at 09:13
  • thanks for links - one user suggests you can use file explorer, but no explanation of how you would go about mounting the emulator FS in order to do this... i'm going to hava a go at /assets first then investigate the SD route – bph Aug 03 '12 at 09:28