Reputation: 595
I have to retrieve Sqlite
database table rows of images.But some rows have no data , that is empty columns are there is database tables.
Here is my database table image
In the above image , there is one ProfilePICURL
column some rows have no data.I have check the length of retrieve ProfilePICURL
string , but not work.So how can i check the row is null. Thanks.
Here is my retrieve method
public void LoadProfilePics()
{
db = myDBHelper.getWritableDatabase();
Cursor cursor = db.rawQuery("select * from Inspector ", null);
if (cursor.moveToFirst())
{
do {
String strProfile_Pics = cursor.getString(cursor.getColumnIndex("ProfilePICURL"));
String strDownLoadStatus = cursor.getString(cursor.getColumnIndex("DownLoadStatus"));
if(strDownLoadStatus.equals("0") && strProfile_Pics.length() != 0)
{
String URL_downLoadProfilePic = namespace + "/DownloadFile/FilePathMobile/PROFILEPICPATH/FileName/" + strProfile_Pics;
newFolder = new File(Environment.getExternalStorageDirectory().getPath() + File.separator + "classNKK_ProfilePic");
download_PngFileImgLoader(URL_downLoadProfilePic, newFolder, strProfile_Pics);
updatedArrayList.add(strProfile_Pics);
Log.e("URL_downLoadProfilePic ", " ==========>" + URL_downLoadProfilePic);
}
} while (cursor.moveToNext());
}
cursor.close();
}
Upvotes: 0
Views: 281
Reputation: 12953
Try this query
Cursor cursor = db.rawQuery("select * from Inspector where profilePICURL IS NULL ", null);
This query will return all the empty/null rows of Profile pic Url.
Upvotes: 0
Reputation: 2529
try this:
String strProfile_Pics = cursor.getString(cursor.getColumnIndex("ProfilePICURL"));
if(strDownLoadStatus.equals("0") &&
strProfile_Pics != null &&
!strProfile_Pics.trim().isEmpty()){
//do stuff
}
Upvotes: 1