« Accessing an Android public directory »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:41pm

ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 sticky  Author  Topic: Accessing an Android public directory  (Read 365 times)
Richard Russell

member is offline


Homepage PM

Posts: 803
xx Accessing an Android public directory
« Thread started on: Jan 14th, 2016, 10:09pm »

Windows provides a number of 'special folders', the paths to which can be discovered by calling the FNspecialfolder() function listed in the BB4W documentation. In a similar way Android provides a number of 'public directories'; I have listed below a function for returning their paths:

      DEF FN_AndroidPublicDirectory(dir$)
      LOCAL path$, path%, clazz%, env%, fid%, mid%, field%, objcls%, object%, string%
      SYS "SDL_AndroidGetJNIEnv" TO env%
      SYS !(!env%+24),  env%, "android/os/Environment" TO clazz% : REM FindClass
      SYS !(!env%+576), env%, clazz%, dir$, "Ljava/lang/String;" TO fid% : REM GetStaticFieldID
      IF fid% = 0 SYS !(!env%+92),  env%, clazz% : = ""
      SYS !(!env%+580), env%, clazz%, fid% TO field% : REM GetStaticObjectField
      SYS !(!env%+452), env%, clazz%, "getExternalStoragePublicDirectory", \
      \                 "(Ljava/lang/String;)Ljava/io/File;" TO mid% : REM GetStaticMethodID
      SYS !(!env%+456), env%, clazz%, mid%, field% TO object% : REM CallStaticObjectMethod
      SYS !(!env%+124), env%, object% TO objcls% : REM GetObjectClass
      SYS !(!env%+132), env%, objcls%, "getAbsolutePath", \
      \                 "()Ljava/lang/String;" TO mid% : REM GetMethodID
      SYS !(!env%+136), env%, object%, mid% TO string% : REM CallObjectMethod
      SYS !(!env%+676), env%, string%, 0 TO path% : REM GetStringUTFChars
      path$ = $$path%
      SYS !(!env%+680), env%, string%, path% : REM ReleaseStringUTFChars
      SYS !(!env%+92),  env%, objcls% : REM DeleteLocalRef
      SYS !(!env%+92),  env%, object% : REM DeleteLocalRef
      SYS !(!env%+92),  env%, field%  : REM DeleteLocalRef
      SYS !(!env%+92),  env%, clazz%  : REM DeleteLocalRef
      = path$ 


The function also serves as an illustration of how accessing the Android OS tends to be more complicated than the equivalent in Windows. This is largely because the API is Java-based rather than the C/C++ API used by Windows.

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls