1

I am trying to get Uri of videos stored in my database so that i can get it as thumbnail, i have successfully converted it in the bitmap but i just cant seem to get Uri of that bitmap so i can display video thumbnail in my List using cursor at the back end. the following line shows Error that its provided by a null value.

Uri Uri1= Uri.parse(path);\\from__NEWS_Feedoverlay---class

please take a look in to the following code fragment

------------------------XXXXXXXXXXMethod from helper class------------------------------------------------------------------------

public Cursor getCursor()
{
    String where=null;
    db= this.getReadableDatabase();
    //db.rawQuery("select image , name from images",null);
    //Cursor cursor = db.rawQuery("select _id, name from images",null);
    Cursor cursor= db.query(true,TABLE_Images,KEY,where,null,null,null,null,null,null);
    if (cursor!=null)
    {
        cursor.moveToFirst();

    }
    return cursor;

------------------------------XXXXXXXXXXXX--NEWS_Feedoverlay---class---------------------

Cursor cursor = helper.getCursor();
        startManagingCursor(cursor);
        //setup for MApping in view fields
        Uri myUri= Uri.parse(helper.KEY_IMAGE);
      // Uri Uri1=  MediaStore.Video.Thumbnails.getContentUri(helper.KEY_FILE);
       Bitmap bMap = ThumbnailUtils.createVideoThumbnail(helper.KEY_FILE, MediaStore.Video.Thumbnails.MICRO_KIND);

        String path = MediaStore.Images.Media.insertImage(getContentResolver(), bMap, "Title", null);
        Uri Uri1= Uri.parse(path);
       // ContentResolver crThumb = getContentResolver();

        //Bitmap bitmap =MediaStore.Video.Thumbnails.getThumbnail(crThumb, Long.parseLong(helper.KEY_FILE),MediaStore.Video.Thumbnails.MICRO_KIND,null);

        String [] fromFieldNames=new String[]{helper.KEY_NAME, String.valueOf(Uri1)};


        int[] toViewID= new int[]{R.id.title,R.id.list_video};
        SimpleCursorAdapter myadaptor= new SimpleCursorAdapter(this, R.layout.list_row, cursor,fromFieldNames,toViewID );
        ListView mylist= (ListView)findViewById(R.id.list);
        mylist.setAdapter(myadaptor);

------------------------------LOGCAT----------------------------

FATAL EXCEPTION: main
                                                                              Process: com.example.sanya.ar_expeditor, PID: 2675
                                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sanya.ar_expeditor/com.example.sanya.ar_expeditor.NewsFeed_Viewoverlay}: java.lang.NullPointerException: uriString
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
                                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:156)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:211)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5371)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740)
                                                                               Caused by: java.lang.NullPointerException: uriString
                                                                                  at android.net.Uri$StringUri.<init>(Uri.java:475)
                                                                                  at android.net.Uri$StringUri.<init>(Uri.java:465)
                                                                                  at android.net.Uri.parse(Uri.java:437)
                                                                                  at com.example.sanya.ar_expeditor.NewsFeed_Viewoverlay.onCreate(NewsFeed_Viewoverlay.java:48)
                                                                                  at android.app.Activity.performCreate(Activity.java:5990)
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) 
                                                                                  at android.app.ActivityThread.access$800(ActivityThread.java:156) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                  at android.os.Looper.loop(Looper.java:211) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                                  at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945) 
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740) 

maybe its the way i convert the video uri into thumbnails but either way its the same ERROR .. i have followed these following links Does anyone know what exactly m doing wrong n how to put it correct..??? thanks... How to get the video thumbnail path, and not the bitmap Android: Is it possible to display video thumbnails?

Community
  • 1
  • 1
user3598648
  • 25
  • 1
  • 6
  • where do you store those thumbnails? do you store an Uri to the thumbnails in your db? – pskink Dec 13 '15 at 19:44
  • @pskink i am not storing thumbnails as i am only getting Uri of Videos from DB then convert it in thumbnail to show in my List in image view. – user3598648 Dec 13 '15 at 19:51
  • `I am trying to get thumbnail of videos stored in my database ...` so what is true and what is false? what does `DatabaseUtils#dumpCursor` show? – pskink Dec 13 '15 at 19:53
  • @pskink oohh yes sorry, i missed that part of saved Uri not thumbnails. i have edited it.. i have ThumbnailUtils not DatabaseUtils.. it is suppose to create thumbnail of given Uri and use it as bitMap. – user3598648 Dec 13 '15 at 20:07
  • what does `DatabaseUtils#dumpCursor` show? – pskink Dec 13 '15 at 20:08
  • @pskink i of waht line you are talking about..??please specify the line – user3598648 Dec 13 '15 at 20:11
  • `Cursor cursor = helper.getCursor();` after that line dump it, post just few rows – pskink Dec 13 '15 at 20:18
  • @pskink but my requirement is to get all the saved data to be displayed.. – user3598648 Dec 13 '15 at 20:32
  • **DatabaseUtils#dumpCursor(Cursor cursor)** `Prints the contents of a Cursor to System.out. The position is restored after printing.` – pskink Dec 13 '15 at 20:34
  • @pskink so i need to close the cursor that's how i can dump it – user3598648 Dec 13 '15 at 20:56
  • you dont know how to dump the Cursor? – pskink Dec 13 '15 at 20:57
  • this is what i get:: >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@1fce72ea I/System.out: 0 {12-14 02:12:55.265 23216-23216/com.example.sanya.ar_expeditor I/System.out: _id=1 12-14 02:12:55.265 23216-23216/com.example.sanya.ar_expeditor I/System.out: name=hey 12-14 02:12:55.265 23216-23216/com.example.sanya.ar_expeditor I/System.out: image=/storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-20151213-WA0005.jpg 12-14 02:12:55.265 23216-23216/com.example.sanya.ar_expeditor I/System.out: file=/storage/sdcard1/DCIM/100ANDRO/MOV_1039.mp4 – user3598648 Dec 13 '15 at 21:16
  • so `fromFieldNames` has to be {"name", "image"} – pskink Dec 13 '15 at 21:23
  • i have three fields in actual code i.e. {"name", "image", "video"} i wrote here code only for two fields{name,video} – user3598648 Dec 13 '15 at 21:26
  • Your db has column "file", not "video" – pskink Dec 13 '15 at 21:28
  • its just a name i mentioned here ..if u can see the Uri m saving is about a video .. and yes the field name is = file – user3598648 Dec 13 '15 at 21:36

0 Answers0