All of the android examples for XmlPullParser pull from a local resource file, and all of the SAX examples pull the XML from a URL. I've been told SAX is faster, so I'm trying to use that to pull data from a local resource file (res/xml/thefile.xml)
The example code I'm working off of is here. So in that example, the code I want to change is:
URL url = new URL("http://example.com/example.xml");
Instead of using URL, I want to use getXml(R.xml.thefile)
Is that possible, or does SAX need to get data from a URL?
I have an XML resource file: <resources> <section> <category value="1" resourceId="@xml/categoryData1" /> <category value="2" resourceId="@xml/categoryData2" /> <category value="3" resourceId="@xml/categoryData3" /> </section> </resources> Using XmlPullParser, on the START_TAG, I can use: int value = parser.getAttributeIntValue(null, "value", 0); to get values 1, 2, 3...however: int resourceId = parser.getAttributeIntValue(null, "resourceId", 0); doesn't work...it just yields the default value 0, or whatever I change the default value (3rd parameter) to be. Does anyone know what I am doing wrong or if this is possible?
I'm trying to read some local files, and ive been reading a lot of stuff about it, but i still don't know where to store the files on my phone and how to get the right path. Some say, it should be stored on /data/data/your.package.here/files but where is that, i mean i can get there when using the emulator but i have no clue how to put files in this on a real device.
Using Local XML file as a database for a android app?
I am trying to build a app with flash using a xml file as database, to read the xml from a external file from the local directory isn't a problem, the problem is how to write data from flash to the xml file.
I don't want to store said file on the sdcard in this case. The file also cannot be storage directly in the apps local files directory. It needs to be in a subdirectory, so it cannot write the file using openFileOutput() and MODE_WORLD_READABLE.
The app may download files small files like pdfs and store them locally in a subdirectory. I would like to be able to have the user open these files if they have an app that can open them.
For example here is an intent for sending a pdf:
path being something like: /data/data/packagename/files/subdir/example.pdf
That intent will open a pdf viewer, but the viewer is unable to open the file. I assume this is a permissions issue. I tried Mark Murphy's suggestion here: http://groups.google.com/group/android-developers/browse_thread/thread/4e55d869213483a9/b7270078ac1a2744?lnk=raot of using Runtime.getRuntime().exec("chmod 755 " + fileName); but it didn't make any difference. He also suggested a Content Provider but I would like to avoid it if I can because it seems like a lot just to get this file over to another app.
If the content provider is the only option, do I have to save the file to the content provider or can I just use the content provider as a pass through to get it to the other app when I need to?
I thought it might be interesting to some developers. Here's a complete working example of ContentProvider for this purpose: http://blog.tourizo.com/2009/02/how-to-display-local-file-in-android. I also found a topic here: http://groups.google.com/group/android-developers/browse_thread/threa. Looks like the topic was closed and I couldn't reply there, so I created new one.
I'm interested in instantiating a LinearLayout object from an xml file that has a LinearLayout file configuration. I want to do this within a method of my Activity. I tried findViewById() but that returned null. I've made sure that the LinearLayout id is the one I'm passing. Note that this layout isn't part of my screen, it's stand-alone, so I want to build a LinearLayout object from the xml.
I am trying to read a file "words.txt" from a resource. It is a very simple, but large (2 MB), text file that I want to read line by line. I have put the file into /res/raw/words.txt, and try to open it with the following code:
However, I get a java.io.IOException. This is not a "resource not found" exception, so the resource is opened correctly, but the readLine() produces the error.
I tried using the InputStream itself, with the result that read() produces -1, which stands for EOF, as if the file was empty.
I have a text file added as a raw resource. The text file contains text like:
a) IF APPLICABLE LAW REQUIRES ANY WARRANTIES WITH RESPECT TO THE SOFTWARE, ALL SUCH WARRANTIES ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF DELIVERY.
b) NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY VIRTUAL ORIENTEERING, ITS DEALERS, DISTRIBUTORS, AGENTS OR EMPLOYEES SHALL CREATE A WARRANTY OR IN ANY WAY INCREASE THE SCOPE OF ANY WARRANTY PROVIDED HEREIN.
c) (USA only) SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER LEGAL RIGHTS THAT VARY FROM STATE TO STATE.
On my screen I have a layout like this:
The code to read the raw resource is:
The text get's showed but after each line I get a strange character  How can I remove that character ? I think it's New Line.
I am trying to get a video to pop up and play. I can get it to work when I use the first uri (that is commented out in the below code), but when I try to use the second uri (from the resource), I get the following error:
From researching the error, it looks like I might have to declare an activity in the manifest but I'm not sure if that applies here?? Can someone point me in the right direction?
This should be very simple, but I can't find the answer anywhere. How do I load an html file (which I assume I keep in res/raw folder) into a webview? neither mWebView.loadUrl("file:///raw/about"); or mWebView.loadUrl("file:///raw/about.htmal"); works. What's the correct syntax or arrangement.
I am trying to get googlemaps to accept a local KML file. final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=file://" + Environment.getExternalStorageDirectory() + "/locate.kml")); startActivity(myIntent);
The file is on the SD card, and is a valid KML file. Google Maps loads up, but says it cannot find the file. final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=http://www.website.com/locate.kml")); startActivity(myIntent);
Works fine. geo: 0,0? q= seems to be very under documented, how to use it to refer to a local file?
I plan to have a 3gp video file that will come with the installation package, it will be placed in /files/ subdirectory, and I would like to ask the native Android media player to play it when I want that.
Here is what I have planned to do/code:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse("BattlestarGalactica.3gp"); intent.setDataAndType(data,"video/3gpp"); startActivity(intent);
However, when I try to launch the lines above, I get the following error:
And the video can not be played.
What am I doing wrong that is not applicable to Android platform?
I am working on a project for a belgium Tv Guide. Now I download a database (.db) file from a server to the sdcard to work with. In this database are 2 tabels, tvchannels and tvprograms. Now I can do several updates to the tvchannels table and i want to make a backup of this table to a lokal database file. How can i do that? I want to do this because I have to download a new database file every daye from the server and the channels that are choses are saved in the tvchannels database. I want to backup this database table and when the new database file (tvgids.db) is downloaded I want to replace the tvchannels database (from downloaded database file) with the backup from tvchannels..
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to email@example.com To unsubscribe from this group, send email to firstname.lastname@example.org For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
I am new to Android and relatively new to Java so please bear with me. I have an XML file stored in the res/xml that I am trying to write to. I know how to read it using XmlResourceParser, but I have not been able to find a way to write to that file locally. Could someone point me in the right direction please.
I would like to get the mime type of my local media file (3gpp , mp4, ...etc) if it is of video then i want to allocate a SurfaceView for it additionally otherwise i just use MediaPlayer to play it i have found opencore has provided some interface for that and used by mediascanner.cpp but it seems in android media framework it isnt so can i achieve this by using android media framework?