This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Searching specific file types in an emulator's internal storage [android studio]

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm new to android development and I'm trying to build a book listing app. I pushed some files in my emulator's sdcard through command line, but they appeared in its internal storage.

Now I'm trying to find a way to access it and load specific book types (such as mobi and epud) through a FloatingActionButton.

I have read and write external storage in permissions in my AndroidManifest and this is my MainActivity as it looks like now through alot of editing in and out code that could help



I am at my wits end... I've been trying to find a solution to just what I'm asking help for for like 2 days and I can't spend more than 2 more days on it 'cos I have alot of other projects to do (opengl, dreamweaver, more java just not in android studio etc) so any help will be greatly appreciated =D
 
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What prints out in the logcat for the value of root and the other values that are printed?

pushed some files in my emulator's sdcard through command line, but they appeared in its internal storage.  


What command did you use to push the files?
Where did you expect them to go besides the internal storage?
 
Christina Cross
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:What prints out in the logcat for the value of root and the other values that are printed?

pushed some files in my emulator's sdcard through command line, but they appeared in its internal storage.  


What command did you use to push the files?
Where did you expect them to go besides the internal storage?



I was informed that Internal storage is part of the memory system that is "local" to an app, which cleared some things for me. I used the adb push "enter path here" "/sdcard/".
I thought they would go on the emulator's SDcard but instead they appear in Storage (through the emulator's settings app) and in Android SDK built for x86 which has multiple folders one of which is Downloads and there my files are. Hope this clears some things that might have otherwise confuse.
I'm gonna post the logcat in my first post so that I won't flood this post and others can find it easily as well. Hope you don't mind
 
Christina Cross
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I can't find edit xD

The logcat for "Show only selected application" is as:

04-13 16:18:37.632 2526-2526/? I/art: Not late-enabling -Xcheck:jni (already on)
04-13 16:18:37.633 2526-2526/? W/art: Unexpected CPU variant for X86 using defaults: x86
04-13 16:18:38.080 2526-2526/com.iekproject.siegfried.libraryapp W/System: ClassLoader referenced unknown path: /data/app/com.iekproject.siegfried.libraryapp-2/lib/x86
04-13 16:18:38.231 2526-2526/com.iekproject.siegfried.libraryapp I/InstantRun: starting instant run server: is main process
04-13 16:18:38.312 2526-2526/com.iekproject.siegfried.libraryapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-13 16:18:38.502 2526-2592/com.iekproject.siegfried.libraryapp E/ActivityThread: Failed to find provider info for com.iekproject.siegfried.libraryapp.data
04-13 16:18:38.532 2526-2593/com.iekproject.siegfried.libraryapp I/OpenGLRenderer: Initialized EGL, version 1.4
04-13 16:18:38.532 2526-2593/com.iekproject.siegfried.libraryapp D/OpenGLRenderer: Swap behavior 1
04-13 16:18:38.532 2526-2593/com.iekproject.siegfried.libraryapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
04-13 16:18:38.532 2526-2593/com.iekproject.siegfried.libraryapp D/OpenGLRenderer: Swap behavior 0
04-13 16:18:38.616 2526-2526/com.iekproject.siegfried.libraryapp W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView


With no filters and a search for root:
04-13 16:18:27.530 1311-1311/? W/cameraserver: type=1400 audit(0.0:5): avc: denied { getattr } for path="/vendor" dev="rootfs" ino=3991 scontext=u:r:cameraserver:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=0
04-13 16:18:27.540 1309-1309/? W/audioserver: type=1400 audit(0.0:6): avc: denied { getattr } for path="/vendor" dev="rootfs" ino=3991 scontext=u:r:audioserver:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=0
04-13 16:18:27.550 1315-1315/? W/mediacodec: type=1400 audit(0.0:7): avc: denied { getattr } for path="/vendor" dev="rootfs" ino=3991 scontext=u:r:mediacodec:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=0
04-13 16:18:27.550 1316-1316/? W/mediadrmserver: type=1400 audit(0.0:8): avc: denied { getattr } for path="/vendor" dev="rootfs" ino=3991 scontext=u:r:mediadrmserver:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=0
04-13 16:18:28.050 1370-1370/? W/bootanimation: type=1400 audit(0.0:9): avc: denied { getattr } for path="/vendor" dev="rootfs" ino=3991 scontext=u:r:bootanim:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=0
04-13 16:18:35.425 1670-1670/com.android.systemui D/ViewRootImpl[StatusBar]: changeCanvasOpacity: opaque=true
 
Norm Radder
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any output from the System.out.println methods in the logcat.  When I debug I get lines like the following:


07-01 03:01:15.141: I/System.out(5827): BLW onCreate() at 2016-07-01 T 03:01:15
07-01 03:01:15.145: I/System.out(5827): BLW onCreate() intent=Intent { flg=0x10000000 cmp=com.normsstuff.batterylevelwarning/.BatteryLevelWarning (has extras) }
07-01 03:01:15.145: I/System.out(5827):  >>data=null
07-01 03:01:15.145: I/System.out(5827):  savedInstanceState=null
07-01 03:01:15.145: I/System.out(5827):  >>extras=Bundle[mParcelledData.dataSize=72]
07-01 03:01:15.169: I/System.out(5827):  >>bndl keySet=[StartedBy]
07-01 03:01:15.173: I/System.out(5827): BLW startedBy=OnAlarmReceive at 2016-07-01 T 03:01:15



What is the value of root on line 73?  Add a print statement to show it.

What is in the list returned by the getfile() called on line 75?

What is in the File array created on line 103?
 
Christina Cross
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:I don't see any output from the System.out.println methods in the logcat.  When I debug I get lines like the following:


07-01 03:01:15.141: I/System.out(5827): BLW onCreate() at 2016-07-01 T 03:01:15
07-01 03:01:15.145: I/System.out(5827): BLW onCreate() intent=Intent { flg=0x10000000 cmp=com.normsstuff.batterylevelwarning/.BatteryLevelWarning (has extras) }
07-01 03:01:15.145: I/System.out(5827):  >>data=null
07-01 03:01:15.145: I/System.out(5827):  savedInstanceState=null
07-01 03:01:15.145: I/System.out(5827):  >>extras=Bundle[mParcelledData.dataSize=72]
07-01 03:01:15.169: I/System.out(5827):  >>bndl keySet=[StartedBy]
07-01 03:01:15.173: I/System.out(5827): BLW startedBy=OnAlarmReceive at 2016-07-01 T 03:01:15



What is the value of root on line 73?  Add a print statement to show it.

What is in the list returned by the getfile() called on line 75?

What is in the File array created on line 103?



I don't know why my logcat doesn't show like yours and I don't know how to make it like that. I have it on Verbose and with either No Filters or with Show Only Selected Application.

The lines you are mentioning are code that I found on the internet and used in the hopes that it will find the files in the external storage and the Downloads file in which they are stored and filter to show/load only the mobi and epub ones
 
Norm Radder
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you add some print statements at the locations I suggested to print the values of those variables?
 
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Internal storage has nothing to do with local to app.  When you call getExternalStorageDirectory() it can refer to either.  Please see the documentation

https://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

If you wish make the a directory local to you app only you should use https://developer.android.com/reference/android/content/Context.html#getFilesDir() i.e context spefic
 
Christina Cross
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:Did you add some print statements at the locations I suggested to print the values of those variables?



I did but I don't know why no SystemOuts appear in the logcat

@Swastik Dey
I'll check those out too thank you
 
Norm Radder
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

don't know why no SystemOuts appear in the logcat


I think you need to get that working to help with the debugging.  I use it a lot.

I use Oracle's VirtualBox for my development/debugging.  I haven't had much luck with the emulators that come with the IDEs.  I also am still using Eclipse.
 
Swastik Dey
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Switch to Studio as fast as you can, and instead of System.out look for Log class.
 
Norm Radder
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

instead of System.out look for Log class.


Is there a way to write the output from the Log class to a file on the device that can be viewed with an editor as needed?  I do not do much testing while connected to  a PC.
I have the System.out print outs go to a file.
 
Swastik Dey
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can see the documentation

https://developer.android.com/reference/android/util/Log.html
 
Norm Radder
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.  I was just reading that and the contents of several pages I got back from Google and did not see where the Log class could write output to a file that could be read with an editor on my device.

So I take it that the Log class can NOT write to a file.
 
Swastik Dey
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an alternate you can always have your customized function to write log to storage

 
Norm Radder
Master Rancher
Posts: 3922
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is sort of what I have done with System.out.  I set it to write to my file.
http://www.dreamincode.net/forums/topic/389160-android-app-debugging-aids/
 
Christina Cross
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Norm Radder I use Android studio and tried using log but it got all red underlined so I don't know what the problem was

@Swastik Dey

Thank you both for the help but I think this app is a lost cause and maybe I went about it the wrong way and only confusing people that are trying to help based on the code already written.
I can't spend more time on it with exams only 2 weeks away and other classes demanding as much time as I spend on it. I'll try to find a simpler app to deliver to my prof.

Again thank you for the help
 
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic