0

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

enter image description here

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();

            }
1
  • Why not use a WHERE clause in the query itself? Commented Feb 17, 2016 at 11:02

2 Answers 2

1

try this:

     String strProfile_Pics = cursor.getString(cursor.getColumnIndex("ProfilePICURL"));
       if(strDownLoadStatus.equals("0") && 
            strProfile_Pics != null && 
               !strProfile_Pics.trim().isEmpty()){
         //do stuff
         }
Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

I don't have to retrieve empty/null rows of Profile pic.I want to avoid empty/null rows while download the Profile pic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.