• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to open directory on android

 
Ranch Hand
Posts: 95
  • Number of slices to send:
    Optional 'thank-you' note:
hi i am trying to open a directory and get file uri after selecting a file but am getting null pointer





but am getting error

 
Saloon Keeper
Posts: 27865
196
  • Number of slices to send:
    Optional 'thank-you' note:
A word of caution.

Android isn't really designed to work with files. Persistent data is commonly kept in (MySQL) databases.

Android itself runs under Linux, so what you would be doing is effectively dropping from Android into the Linux OS. Significantly, Android doesn't run as a privileged user in its host OS, so in many cases Android apps cannot access files/directories as they are owned by a different userID.
 
Rancher
Posts: 5008
38
  • Number of slices to send:
    Optional 'thank-you' note:
Did you see this:
https://stackoverflow.com/questions/53748248/java-lang-nullpointerexception-attempt-to-invoke-virtual-method-android-app-ac
 
john bean
Ranch Hand
Posts: 95
  • Number of slices to send:
    Optional 'thank-you' note:
thanks for replys what i am trying to do is navagate through phone and select a file for mediaplayer and save the link in my app sorry have not replied sonner windows broke my debian I HATE WINDOWS!
 
Tim Holloway
Saloon Keeper
Posts: 27865
196
  • Number of slices to send:
    Optional 'thank-you' note:
Hmm. I mostly just launch Mediaplayer straight from the File Manager app actually. I think VLC can create playlists on Android devices, and you can use File Manager to create a media "save list" directory as well.

The File Manager is kind of quirky, as it has to deal with both built-in (permanent) storage and swappable (SD card) storage, so that's also a consideration.
 
Saloon Keeper
Posts: 7597
177
  • Number of slices to send:
    Optional 'thank-you' note:
I think an approach like https://developer.android.com/training/data-storage/shared/documents-files#open-file is more in tune with current Android practices.
 
Greenhorn
Posts: 3
  • Number of slices to send:
    Optional 'thank-you' note:
First, "External" is "external to the app". On newer versions of Android you need whole new practices for that: Try to read about content manager and saving docs.
That content manager has an internal database under the hood, and you have to let Android manage those files for you.
Avoid storing files in a fixed position. Android won't let you, since 12 - if I remember correctly. The global storage party is over :-(
If you need to share files, consider storing them in your app area (maybe Cache if you don't care much about them after sharing), and use **content providers** (a mechanism that allows apps to share pieces of data to the outside via some URL. It's a little boilerplate... well).
If you must use external storage, be aware that Android requires lots of frightening permissions (some kind of "full storage access").

Now, note that this maps basically to /sdcard/Files. Does this directory exist?
Don't use getenv("EXTERNAL_STORAGE") + "/Files"
Use File(Environment.EXTERNAL_STORAGE_something, "Files").
That's because you want to see where it puts you. With the debugger, when you inspect a File() object, you can view the absolute path (usually also with toString()), and check if isFile() or isDir() or exists().

Oh, and ... Tim Holloway: NOT MySQL! It's always SQLite! < Covering the eyes of children here :-D >
 
Tim Holloway
Saloon Keeper
Posts: 27865
196
  • Number of slices to send:
    Optional 'thank-you' note:
Yeeks! I said MySQL??? What was I thinking???

SQLite it is.
 
john bean
Ranch Hand
Posts: 95
  • Number of slices to send:
    Optional 'thank-you' note:
thanks for replys have hit have been afk for a few week "f ing work!" but have hit an unusual problem ... my phone samsung a14g5 did a software update and now im getting runtime error
 E  FATAL EXCEPTION: main
                                                                         

this seems to be a prob at samsung os level my eq works on emulator but when run on phone it crashes at launch but i have tried a few different eqs and they work does anyone know a fix?

the code throwing error is


thanks for any help
 
Marshal
Posts: 28262
95
  • Number of slices to send:
    Optional 'thank-you' note:
The code you posted simply takes the integer value it's given and throws a suitable exception which corresponds to that value. So some other code has had a problem and called that method to throw an exception.

In other words, the posted code tells us nothing about the problem, except what the words in the exception say. The stack trace tells us that the method "android.media.audiofx.Equalizer.usePreset" had that problem.
 
john bean
Ranch Hand
Posts: 95
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:
k just an update when running i got error i uninstalled on device then tried and it worked sry should have tried that
 
Paul Clapham
Marshal
Posts: 28262
95
  • Number of slices to send:
    Optional 'thank-you' note:
Yeah, I always forget the "uninstall and reinstall" method for fixing Android apps too. Anyway, thanks for letting us know!
 
Tim Moores
Saloon Keeper
Posts: 7597
177
  • Number of slices to send:
    Optional 'thank-you' note:

I always forget the "uninstall and reinstall" method for fixing Android apps too.


It's really disappointing that this Windows approach to troubleshooting also applies to a Linux OS like Android.
 
Tim Holloway
Saloon Keeper
Posts: 27865
196
  • Number of slices to send:
    Optional 'thank-you' note:
Windows locks files based on their names, so a lot of system updates can only be done when no process has locked files affected by the update. Essentially, for a short period in the Windows Boot process, Windows is running invisibly in "DOS" mode where you don't have all those processes locking the files. Unix/Linux are not so constrained because they lock on inodes, and the connection between filename and inode can be re-mapped to another inode at almost any time, with existing holders of the old node retaining it until they release it. A side effect of that being that you can delete an open file, but the space it uses won't be freed until after the file is closed.

Android apps, on the other hand are more like a bundle of running classes and replacing running code on the fly is trickier than re-pointing to a different file, since you have to evict the old code from the classloader.

Actually Java had a really bad problem for certain Tomcat releases because back then Java supported a special memory partition called "PermGen" space. Certain static objects would get stored in PermGen and couldn't be replaced without restarting the JVM. which meant that even though Tomcat supported (and still supports) hot updates on apps, their PermGen components would remain and eventually you'd be forced to restart when the PermGen space ran out.
 
Paul Clapham
Marshal
Posts: 28262
95
  • Number of slices to send:
    Optional 'thank-you' note:

Tim Moores wrote:

I always forget the "uninstall and reinstall" method for fixing Android apps too.


It's really disappointing that this Windows approach to troubleshooting also applies to a Linux OS like Android.


Indeed it is. But it's worked for me twice. (Both times on obscure apps which weren't highly rated.)

I'd blame the apps rather than the OS, although it's hard (for me) to see why an app should one day start declaring that it can't play any WAV files, that being one of its standard features.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |