Cellidwriter class continues here publicvoid write cid
Using files |
---|
Reading files from resources
• Raw files are processed by aapt and must be referenced from the application using a resource identifier in the R class
• Asset files are compiled into the .apk file as-is and you can navigate this directory in the same way as a typical file system
|
---|
• Every application can read and write from/to the SD card (external memory) but needs permissions in AndroidManifest
– Write needs the WRITE_EXTERNAL_STORAGE permission
irectory | |
---|---|
|
|
worked, false otherwise ion’s private area in a String array java.io.FileInputStream java.io.FileOutputStream ; |
|
|
---|
– Use with DIRECTORY_*** to
get the standard directory
locations• getExternalStorageDirectory()
|
---|
– Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
|
|
---|---|
|
|
|
||
---|---|---|
|
||
|
---|
|
---|
|
||
---|---|---|
|
![]() |
Wi-Fi |
---|
|
|
---|
|
---|
} | |||
---|---|---|---|
|
|||
|
|||
// android does flush() in close() | |||
System.err.println(e.toString() + | |||
|
|||
|
|||
|
---|
|
---|
|
---|
When Android needs to kill applications to save resources, Services has high priority, only second to foreground Activities
Other components can start and stop the service, it can also stop itself While it is running other components can bind to it (if implemented) Consider using a Service when the application
– performs a lengthy or intensive processing, not requiring user interaction – performs certain tasks at regular intervals, e.g. downloading updates of some content
– performs lengthy operations that shouldn’t be canceled if the application exits, e.g. downloading a large file
– needs to provide data or information services to other applications (without an user interface)
Service 2 | ![]() |
---|
A service runs in the main thread of its hosting process
– Any CPU intensive work or blocking operations should be performed by spawning a worker thread!
|
---|
Creating a simple service
Declare the service in your Androidmanifest inside the application tag
|
---|
|
---|
|
---|