I am trying to use VectorDrawables in my android application.
I want to download the xml file from the file system and get an instance of android.graphics.Drawable in order to display it in ImageView . If I add the xml file to the resource directory, it will work. But when I try to download it from the file system, I always get NullPointer.
I'm currently trying to upload a file via Drawable.createFromPath(*Path to File*) or VectorDrawable.createFromPath(*Path to File*) , but I keep getting NullPointer. The file exists and is a valid xml file (see below).
In adb log, I always get:
SkImageDecoder::Factory returned null
When I use mContext.getFilesDir() , the Path looks something like this:
/data/data/*packagename*/files/*filename*.xml
I also tried some public folders like "Downloads". When I check the file with File.io Api, it exists() , canRead() and canWrite()
Refresh . This is XML code taken from Android Dev pages.
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="64dp" android:width="64dp" android:viewportHeight="600" android:viewportWidth="600" > <group android:name="rotationGroup" android:pivotX="300.0" android:pivotY="300.0" android:rotation="45.0" > <path android:name="v" android:fillColor="#000000" android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" /> </group>
source share