i'm getting a null pointer exception at the following code.
This is my resource file
<array name="category_colors">
<item>#e57373</item>
<item>#ef5350</item>
<item>#f44336</item>
<item>#e53935</item>
<item>#d32f2f</item>
</array>
And this my function with the exception at "Color.parseColor"
private void insertCategories(String[] titles, String[] colors) {
int i = 0;
for (String title : titles) {
final Category category = new Category();
category.setTitle(title);
category.setColor(Color.parseColor(colors[i % colors.length]));
i++
db.insert(Tables.Categories.TABLE, null, category.toContentValues());
}
}
This is the calling method...
insertCategories(context.getResources().getStringArray(R.array.categories),
context.getResources().getStringArray(R.array.category_colors));
And my error :)
java.lang.NullPointerException: Attempt to invoke virtual method 'char java.lang.String.charAt(int)'
I debugged the resource and they are available. In my other project the code works fine... Can anybody help me? Thx