Cannot read some files names from asset folder - android

I can read the file names from Asset folder but it is skipping the few file names
It looks like it is only able list me the names which are in English rest of the names i.e non english are skipped . I have attached a image. In image you can see the code , asset folder and Log of the list that i get .
Thanks for your help .

As far as i know, non-english characters are not allowed in filenames inside APK

renaming folder using small letter without character..
I think it's work..

Related

How to access an image file from assets in Flutter that has spaces in it's name?

Working on a Flutter application project that has some absurd naming conventions from the design team which prepares image assets, therefore the following question.
What's the syntax to access an image file which has spaces in it's name? For example I have an image named "United Arab Emirates.png" residing in my assets path i.e "assets/Flags/United Arab Emirates.png" When I try to access this path in Image.asset() widget I am unable to load it because the image has spaces in it's name. If I remove the space I can load it and show it in the widget. The problem here is I can not rename a huge amount of images I have in my assets directory and don't know how to write a script to rename all the assets and don't want to invest time learning how to write a script.
There must be some syntax to access these assets as I think this is a pretty generic issue that should have happened with lot of people but I don't see any questions or answer posted regarding this.
I think flutter add assets to embed , like res/draw in android, not assets folder, so the filename can not include space or other unexpected chars

How to store and get internal app data from file in Android?

I am writing a simple Android Sudoku app, during the first stage, I want to store some Sudoku puzzle in a file and then get them. The file is a simple xml file, it's format just like:
<puzzle>23000...31</puzzle>
<puzzle>45013...67</puzzle>
There are 9 * 9 character in "puzzle" tag.
My question is, what's the correct directory for the file, and how to get the data from it?
You can store your file in assets directory or even raw directory. Honestly, I would advise you to use the first solution: you will then be able to use inside your code:
getAssets().open(fileName)
"assets" directory has to be at the root of your project (same level as ""src", "res", "libs"...
"raw" directory has to be inside the "res" one.

Data in XML: where to place it

I am trying to design a new Android application.
For that application I will have an XML file that will be located somewhere on the server. This file will be generated from the mySQL DB.
For now (developmental phase) I got a simple and small XML file that I need to put in the Android Eclipse project in order to read it and present the data on the phone.
I just tried to put this file in res/values, but compiler gives me an error: "Invalid start tag".
Looking through the stackoverflow and google I see a lot of different answers and google even give me an answer of how to parse xml file on Android. ;-)
So is there a "standard" place where such XML file goes in Android Eclipse project? Think about it as the data that is read from the DB.
Some answers are to place it in the res/xml folder. I just made a brand new Android project and I don't see such folder in it. Do I create one? Shouldn't it be done automatically?
Some says you need to put it the res/raw folder. Again it is not present in the Eclipse project. Do I make one? Shouldn't it be present already?
Please clarify.
Shouldn't it be present already?
It doesn't have to. There can be thousands of folders inside res/ folder. You don't want to have them all at first.
Do I make one?
Yes. Add folders when you need them.
Some answers are to place it in the res/xml folder.
Some says you need to put it the res/raw folder.
The difference between these folders is that files inside raw stay the same you put them and inside xml are parsed when APK is created and put there in a binary, optimized form, similar to what happens to layouts, AndroidManifest and other.

How to load an xml file from android's assets folder by name

I am trying to load an xml file located in the /assets folder of an android project by name using this method:
getAssets().openXmlResourceParser("thefilename.xml");
However, executing this code always throws a "FileNotFound" exception, even though the file is located in the /assets folder and is with the correct file name.
Now, I have not put the file in the /res/xml folder because I really need to be able to 1. edit the file right on the device itself and most importantly 2. add new xml files to the application without issuing an update, to allow for easy user modifications.
Thanks in advance.
I think what you are looking for is either getAssets().open("thefilename.xml") or getAssets().openFd("thefilename.xml") depending on what the end use of the file is. You can see from Dianne's response in this post awhile back that openXmlResourceParser() is not really usable just to gain access to files in the assets/ directory: http://goo.gl/2KfgT
From there you will have a stream that you could feed into a SAXParser or do whatever else you choose.
Side Note: On the points you mentioned you really can't edit files directly in assets/ or add new files to assets/ at runtime. You will need to work with files on either internal or external storage to do those things. You probably already knew that, but I thought I'd mention it.
Hope that Helps!

4 MB .txt file in android application

I have a really big .txt file ( 4.2MB) that I have to access in my android application. It consists of words and their definitions in this format:
word - definition
word2 - definition2
Should I put this file in /assets folder or in res/raw? Or something third? Maybe I should put it on SD card because of its size?
And how should I get file contents in the code?
I have tried both assets and res/raw, but the file size always seems to be the problem or I am doing something wrong.
A SQLLite database could be used for this.
An example of this can be found in the latest android SDK. http://developer.android.com/resources/samples/SearchableDictionary/index.html
Putting it in raw folder would be a better idea according to me.
since putting in the SDCard would make it available to user also, and the user might screw up your database.

Categories

Resources