I want to check the equality of image file path name . When run the app , the application crash and getting error in Constructor in Adapter class at for loop sentence is = for(int n = 0; n <= mStringArray.length; n++) in My Adapter Class.
Here is my ImageAdapter class Consrtuctor
public ImageAdapter(Context c, String[] fpath) {
context = c;
filepath = fpath;
TypedArray a = obtainStyledAttributes(R.styleable.MyGallery);
itemBackground = a.getResourceId(R.styleable.MyGallery_android_galleryItemBackground, 0);
a.recycle();
if (newFolder.isDirectory()) {
listFile = newFolder.listFiles();
filepath = new String[listFile.length];
for (int i = 0; i < listFile.length; i++)
{
filepath[i] = listFile[i].getAbsolutePath();
Log.e(" filepath[i] " , " = " + filepath[i]);
}
for(int m = 0 ; m <= filepath.length; m++)
{
String firstValue= filepath[m];
Log.e("Image is ","firstValue = " + firstValue);
for(int n = 0; n <= mStringArray.length; n++)
{
String SecondValue = mStringArray[n];
Log.e("Image is ","Secondvalue = " + SecondValue);
if(firstValue.equalsIgnoreCase(SecondValue))
{
Log.e("Image is ","Equal");
}
else
{
Log.e("Image is ","Not Equal");
}
}
}
}
}
Here is my Sqlite Query method
public List<String> getAll_ImageAudioPath() {
labels = new ArrayList<String>();
dbhelper = new MyDbHelper(this);
SQLiteDatabase db = dbhelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from ActivityObjectList where activityId ='" + strDescription + "'", null);
if (cursor.moveToFirst()) {
do {
labels.add(cursor.getString(cursor.getColumnIndex("imageaudioPath")));
} while (cursor.moveToNext());
}
cursor.close();
db.close();
int strLabelSize = labels.size();
Log.e("Value of strLabelSize ", " = " + strLabelSize);
for (int i = 0; i < labels.size(); i++) {
Log.e("Value of element ", " = " + i + " & " + labels.get(i));
strLablepath = labels.get(i);
Log.e("Value of strLablepath ", " = " + strLablepath);
mStringArray = new String[labels.size()];
mStringArray = labels.toArray(mStringArray);
for(int x = 0; x < mStringArray.length ; x++){
Log.e("mStringArray[i] is","" + mStringArray[i]);
}
}
Can someone help me how to compare the two String Array with image path in Image Adapter.Thanks to appreciate.