Android Question Populating ListView from SQLite table

Declan

Well-Known Member
Licensed User
Longtime User
I am reading all the Images in the Phone Gallery.
I then "filter" these images so that I only write the File Name and Image of files that are less than 8 days old to the SQLite table "gallery".
I write both the File Name and the image (BLOB) to the table "gallery".
I then populate the ListView "lvTip" from the SQLite table "gallery".
I receive the following error on line:
B4X:
PicName = Curs.GetString("picName")
Error:
B4X:
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
As can be seen from the Log, I do have data in the table "gallery".
Log:
B4X:
Copying updated assets files (8)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
true
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Error: java.net.ConnectException: failed to connect to /197.189.232.202 (port 18100) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
** Activity (main) Pause, UserClosed = false **
** Activity (tip) Create, isFirst = true **
** Activity (tip) Resume **
DropTable: DROP TABLE IF EXISTS [gallery]
CreateTable: CREATE TABLE IF NOT EXISTS [gallery] ([picName] TEXT, [galleryPic] BLOB)
Gallery Table Created
File List = (ArrayList) [IMG_20161018_065705.jpg, IMG_20161102_084539.jpg, IMG_20161102_084553.jpg, IMG_20161102_084603.jpg, IMG_20161102_084623.jpg, IMG_20161102_084627.jpg, IMG_20161102_084630.jpg, SAVE_20161111_112027.png, IMG_20161116_081510.jpg, IMG_20161116_081513.jpg, IMG_20161116_081516.jpg, IMG_20161121_101052.jpg, IMG_20161121_101056.jpg, IMG_20161121_101104.jpg, IMG_20161121_101109.jpg, IMG_20161121_101115.jpg, IMG_20161121_101124.jpg, IMG_20161225_074426.jpg, IMG_20161225_074503.jpg, IMG_20161225_074518.jpg, IMG_20161101_183650.jpg, IMG_20161225_074631.jpg, IMG_20161225_074804.jpg, IMG_20161225_074913.jpg, IMG_20161225_074934.jpg, IMG_20161225_075153.jpg, IMG_20161225_075208.jpg, IMG_20161225_075417.jpg, IMG_20161225_075449.jpg, IMG_20170109_220002.jpg, IMG_20170109_220006.jpg, IMG_20170109_220011.jpg, IMG_20170109_220020.jpg, IMG_20170110_054009.jpg, IMG_20170110_054012.jpg, IMG_20170110_054012_1.jpg, IMG_20170110_054012_1_BURST2.jpg, IMG_20170110_054039.jpg, IMG_20161225_074103.jpg, IMG_20161225_074118.jpg, IMG_20161225_074120.jpg, IMG_20161225_074218.jpg, IMG_20161225_074222.jpg, IMG_20170110_120837.jpg, IMG_20170110_122431.jpg, IMG_20170113_091031.jpg, IMG_20170113_091038.jpg, IMG_20170113_091052.jpg, IMG_20170120_085349.jpg, IMG_20170120_085355.jpg, IMG_20170120_103407.jpg, IMG_20170120_103414.jpg, IMG_20170120_103426.jpg, IMG_20170120_103429.jpg, IMG_20170120_103433.jpg, IMG_20170120_103436.jpg, IMG_20170120_103442.jpg, IMG_20170120_103443.jpg, IMG_20170120_103502.jpg, IMG_20170121_105105.jpg, IMG_20170121_105117.jpg, IMG_20170121_111402.jpg, IMG_20170121_111406.jpg, IMG_20170121_111421.jpg, IMG_20170121_111423.jpg, IMG_20170121_111433.jpg, IMG_20170121_111438.jpg, IMG_20170121_111538.jpg, IMG_20170121_111551.jpg, IMG_20170121_111602.jpg, IMG_20170121_111613.jpg, IMG_20170121_111628.jpg, IMG_20170121_111632.jpg, IMG_20170121_111642.jpg, IMG_20170121_111713.jpg, IMG_20170121_111733.jpg, IMG_20170121_111740.jpg, IMG_20170121_111741.jpg, IMG_20170121_111748.jpg, IMG_20170121_111754.jpg, IMG_20170121_112057.jpg, IMG_20170122_133807.jpg, IMG_20170122_133818.jpg, IMG_20170122_133907.jpg, IMG_20170122_133913.jpg, IMG_20170122_133913_1.jpg, IMG_20170122_133926.jpg, IMG_20170122_133931.jpg, IMG_20170217_172841.jpg, IMG_20170217_172844.jpg, IMG_20170217_172845.jpg, IMG_20170217_173010.jpg, IMG_20170224_080939.jpg, IMG_20170224_080946.jpg, IMG_20170309_121014.jpg, IMG_20170309_121025.jpg, IMG_20170309_121028.jpg, IMG_20170314_080944.jpg]
File Count = 98
Picture Name: IMG_20161018_065705.jpg
Number of Days: 148
Picture Name: IMG_20161102_084539.jpg
Number of Days: 133
Picture Name: IMG_20161102_084553.jpg
Number of Days: 133
Picture Name: IMG_20161102_084603.jpg
Number of Days: 133
Picture Name: IMG_20161102_084623.jpg
Number of Days: 133
Picture Name: IMG_20161102_084627.jpg
Number of Days: 133
Picture Name: IMG_20161102_084630.jpg
Number of Days: 133
Picture Name: SAVE_20161111_112027.png
Picture Name: IMG_20161116_081510.jpg
Number of Days: 119
Picture Name: IMG_20161116_081513.jpg
Number of Days: 119
Picture Name: IMG_20161116_081516.jpg
Number of Days: 119
Picture Name: IMG_20161121_101052.jpg
Number of Days: 114
Picture Name: IMG_20161121_101056.jpg
Number of Days: 114
Number of Days: 64
Picture Name: IMG_20170110_054012_1.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1_BURST2.jpg
Number of Days: 64
Picture Name: IMG_20170110_054039.jpg
Number of Days: 64
Picture Name: IMG_20161225_074103.jpg
Number of Days: 80
Picture Name: IMG_20161225_074118.jpg
Number of Days: 80
Picture Name: IMG_20161225_074120.jpg
Number of Days: 80
Picture Name: IMG_20161225_074218.jpg
Number of Days: 80
Picture Name: IMG_20161225_074222.jpg
Number of Days: 80
Picture Name: IMG_20170110_120837.jpg
Number of Days: 64
Picture Name: IMG_20170110_122431.jpg
Number of Days: 64
Picture Name: IMG_20170113_091031.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1_BURST2.jpg
Number of Days: 64
Picture Name: IMG_20170110_054039.jpg
Number of Days: 64
Picture Name: IMG_20161225_074103.jpg
Number of Days: 80
Picture Name: IMG_20161225_074118.jpg
Number of Days: 80
Picture Name: IMG_20161225_074120.jpg
Number of Days: 80
Picture Name: IMG_20161225_074218.jpg
Number of Days: 80
Picture Name: IMG_20161225_074222.jpg
Number of Days: 80
Picture Name: IMG_20170110_120837.jpg
Number of Days: 64
Picture Name: IMG_20170110_122431.jpg
Number of Days: 64
Picture Name: IMG_20170113_091031.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1_BURST2.jpg
Number of Days: 64
Picture Name: IMG_20170110_054039.jpg
Number of Days: 64
Picture Name: IMG_20161225_074103.jpg
Number of Days: 80
Picture Name: IMG_20161225_074118.jpg
Number of Days: 80
Picture Name: IMG_20161225_074120.jpg
Number of Days: 80
Picture Name: IMG_20161225_074218.jpg
Number of Days: 80
Picture Name: IMG_20161225_074222.jpg
Number of Days: 80
Picture Name: IMG_20170110_120837.jpg
Number of Days: 64
Picture Name: IMG_20170110_122431.jpg
Number of Days: 64
Picture Name: IMG_20170113_091031.jpg
Picture Name: IMG_20170121_111551.jpg
Number of Days: 53
Picture Name: IMG_20170121_111602.jpg
Number of Days: 53
Picture Name: IMG_20170121_111613.jpg
Number of Days: 53
Picture Name: IMG_20170121_111628.jpg
Number of Days: 53
Picture Name: IMG_20170121_111632.jpg
Number of Days: 53
Picture Name: IMG_20170121_111642.jpg
Number of Days: 53
Picture Name: IMG_20170121_111713.jpg
Number of Days: 53
Picture Name: IMG_20170121_111733.jpg
Number of Days: 53
Picture Name: IMG_20170121_111740.jpg
Number of Days: 53
Picture Name: IMG_20170121_111741.jpg
Number of Days: 53
Picture Name: IMG_20170121_111748.jpg
Number of Days: 53
Picture Name: IMG_20170121_111754.jpg
Number of Days: 53
Picture Name: IMG_20170121_112057.jpg
Number of Days: 53
Picture Name: IMG_20170122_133807.jpg
Number of Days: 52
Picture Name: IMG_20170122_133818.jpg
Number of Days: 52
Picture Name: IMG_20170122_133907.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913_1.jpg
Number of Days: 52
Picture Name: IMG_20170122_133926.jpg
Number of Days: 52
Picture Name: IMG_20170122_133931.jpg
Number of Days: 52
Picture Name: IMG_20170217_172841.jpg
Number of Days: 26
Picture Name: IMG_20170217_172844.jpg
Number of Days: 53
Picture Name: IMG_20170121_111754.jpg
Number of Days: 53
Picture Name: IMG_20170121_112057.jpg
Number of Days: 53
Picture Name: IMG_20170122_133807.jpg
Number of Days: 52
Picture Name: IMG_20170122_133818.jpg
Number of Days: 52
Picture Name: IMG_20170122_133907.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913_1.jpg
Number of Days: 52
Picture Name: IMG_20170122_133926.jpg
Number of Days: 52
Picture Name: IMG_20170122_133931.jpg
Number of Days: 52
Picture Name: IMG_20170217_172841.jpg
Number of Days: 26
Picture Name: IMG_20170217_172844.jpg
Number of Days: 53
Picture Name: IMG_20170121_111754.jpg
Number of Days: 53
Picture Name: IMG_20170121_112057.jpg
Number of Days: 53
Picture Name: IMG_20170122_133807.jpg
Number of Days: 52
Picture Name: IMG_20170122_133818.jpg
Number of Days: 52
Picture Name: IMG_20170122_133907.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913_1.jpg
Number of Days: 52
Picture Name: IMG_20170122_133926.jpg
Number of Days: 52
Picture Name: IMG_20170122_133931.jpg
Number of Days: 52
Picture Name: IMG_20170217_172841.jpg
Number of Days: 26
Picture Name: IMG_20170217_172844.jpg
Number of Days: 26
Picture Name: IMG_20170217_172845.jpg
Number of Days: 26
Picture Name: IMG_20170217_173010.jpg
Number of Days: 26
Picture Name: IMG_20170224_080939.jpg
Number of Days: 19
Picture Name: IMG_20170224_080946.jpg
Number of Days: 19
Picture Name: IMG_20170309_121014.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170309_121014.jpg, galleryPic=[B@1446a0c}]
Picture Name: IMG_20170309_121025.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170309_121025.jpg, galleryPic=[B@3b8ff55}]
Picture Name: IMG_20170309_121028.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}]
Gallery Rows Count: 4
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}]
Gallery Rows Count: 4
Error occurred on line: 141 (Tip)
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
    at android.database.AbstractCursor.checkPosition(AbstractCursor.java:466)
    at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
    at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at com.rob.crimechat.tip._loadpictures(tip.java:483)
    at com.rob.crimechat.tip._btntipaddphoto_click(tip.java:475)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:5207)
    at android.view.View$PerformClick.run(View.java:21177)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5438)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

My Code:
B4X:
    Dim MyPicsDate As String
    Dim MyDateToday As Long
  
    DBUtils.DropTable(Starter.SQL0, "gallery")
    Dim m As Map
    m.Initialize
    m.Put("picName", DBUtils.DB_TEXT)
    m.Put("galleryPic", DBUtils.DB_BLOB)
    DBUtils.CreateTable(Starter.SQL0, "gallery", m, "")
    Log("Gallery Table Created")
  
    Dim ImageList As List
    Dim ImageCount As Int
    ImageList = File.ListFiles("/storage/emulated/0/DCIM/Camera/")
    ImageCount = ImageList.Size

    Log("File List = " & ImageList)
    Log("File Count = " & ImageCount)
  
    If ImageCount = 0 Then
        ToastMessageShow("You have No Pictures in Your Gallery",False)
        Activity.Finish
    End If
  
    For i = 0 To ImageCount - 1
        MyPictureName = (ImageList.Get (i))
        Log("Picture Name: " & MyPictureName)
        Dim IsImage As String
        IsImage = sf.Mid(MyPictureName,1,4)
      
        If IsImage = "IMG_" Then
      
            MyPicsDate = sf.Mid(MyPictureName,5,8)
            DateTime.DateFormat = "yyyyMMdd"
            DateTime.TimeFormat = "hh:mm:ss"
            MyDateToday = DateTime.Date(DateTime.Now)
            Dim p As Period = DateUtils.PeriodBetweenInDays(DateTime.DateParse(MyPicsDate), DateTime.DateParse(MyDateToday) )
            Log("Number of Days: " & p.days)

            If p.Days < 8 Then
                'convert the image file to a bytes array
                Dim InputStream1 As InputStream
                InputStream1 = File.OpenInput(File.DirRootExternal & "/DCIM/Camera/",MyPictureName)'(File.DirRootExternal, "MyPortrait.jpg")
                Dim OutputStream1 As OutputStream
                OutputStream1.InitializeToBytesArray(1000)
                File.Copy2(InputStream1, OutputStream1)
                Dim Buffer() As Byte
                Buffer = OutputStream1.ToBytesArray
              
                'write the filename & image to the database
                Dim ListOfMaps As List
                ListOfMaps.Initialize
                Dim m As Map
                m.Initialize
                m.Put("picName", MyPictureName)
                m.Put("galleryPic", Buffer)
                ListOfMaps.Add(m)
                DBUtils.InsertMaps(Starter.SQL0, "gallery", ListOfMaps)
                LogColor("List: " & ListOfMaps, Colors.Blue)
                ListOfMaps.Clear
            End If
        End If
    Next

' Load ListView (lvTip)
    lvTip.clear
    Dim Curs As Cursor
    Curs = Starter.SQL0.ExecQuery("SELECT * FROM gallery")
    If Curs.RowCount = 0 Then
        ToastMessageShow("There are no pictures in Gallery",False)
        Activity.Finish
    Else
          
        LogColor("Gallery Rows Count: " & Curs.RowCount, Colors.Blue)
              
        lvTip.SingleLineLayout.ItemHeight = 1dip
        lvTip.SingleLineLayout.Label.Color = Colors.LightGray
        lvTip.TwoLinesAndBitmap.ItemHeight = 120dip
        lvTip.TwoLinesAndBitmap.ImageView.Height = 80dip
        lvTip.TwoLinesAndBitmap.ImageView.Width = 80dip
        lvTip.TwoLinesAndBitmap.ImageView.top = 20dip

        lvTip.TwoLinesAndBitmap.SecondLabel.Height = 80dip
        lvTip.TwoLinesAndBitmap.SecondLabel.left = (((lvTip.TwoLinesAndBitmap.ImageView.Left) + (lvTip.TwoLinesAndBitmap.ImageView.Width)) + 5dip)
        lvTip.TwoLinesAndBitmap.Label.TextColor=Colors.LightGray
        lvTip.TwoLinesAndBitmap.Label.TextSize = 20
        lvTip.TwoLinesAndBitmap.Label.Left = (((lvTip.TwoLinesAndBitmap.ImageView.Left) + (lvTip.TwoLinesAndBitmap.ImageView.Width)) + 5dip)
        For i=0 To Curs.RowCount-1
            Curs.Position=i
            Dim Buffer() As Byte
            Dim PicName As String

            PicName = Curs.GetString("picName")
            Buffer = Curs.GetBlob("galleryPic")
          
            Dim Line1 As String
            Dim Line2 As String
          
            Line1 = "File Name:"
            Line2 = PicName
          
            Dim InputStream1 As InputStream
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
            Dim Bitmap1 As Bitmap
            Bitmap1.Initialize2(InputStream1)
            InputStream1.Close
            lvTip.AddTwoLinesAndBitmap(Line1,Line2 , Bitmap1)

            lvTip.AddSingleLine("")
        Next
        Curs.Close

    End If
I can't seem to find what I am doing wrong.
 

Declan

Well-Known Member
Licensed User
Longtime User
Output for:
B4X:
For c = 0 To Curs.ColumnCount - 1
      Log("Column Name: " & Curs.GetColumnName (c))
Next
Is:
B4X:
Column Name: picName
Column Name: galleryPic
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
This is the full error message from the logs:
B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
true
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Error: java.net.ConnectException: failed to connect to /197.189.232.202 (port 18100) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
** Activity (main) Pause, UserClosed = false **
** Activity (tip) Create, isFirst = true **
** Activity (tip) Resume **
DropTable: DROP TABLE IF EXISTS [gallery]
CreateTable: CREATE TABLE IF NOT EXISTS [gallery] ([picName] TEXT, [galleryPic] BLOB)
Gallery Table Created
File List = (ArrayList) [IMG_20161018_065705.jpg, IMG_20161102_084539.jpg, IMG_20161102_084553.jpg, IMG_20161102_084603.jpg, IMG_20161102_084623.jpg, IMG_20161102_084627.jpg, IMG_20161102_084630.jpg, SAVE_20161111_112027.png, IMG_20161116_081510.jpg, IMG_20161116_081513.jpg, IMG_20161116_081516.jpg, IMG_20161121_101052.jpg, IMG_20161121_101056.jpg, IMG_20161121_101104.jpg, IMG_20161121_101109.jpg, IMG_20161121_101115.jpg, IMG_20161121_101124.jpg, IMG_20161225_074426.jpg, IMG_20161225_074503.jpg, IMG_20161225_074518.jpg, IMG_20161101_183650.jpg, IMG_20161225_074631.jpg, IMG_20161225_074804.jpg, IMG_20161225_074913.jpg, IMG_20161225_074934.jpg, IMG_20161225_075153.jpg, IMG_20161225_075208.jpg, IMG_20161225_075417.jpg, IMG_20161225_075449.jpg, IMG_20170109_220002.jpg, IMG_20170109_220006.jpg, IMG_20170109_220011.jpg, IMG_20170109_220020.jpg, IMG_20170110_054009.jpg, IMG_20170110_054012.jpg, IMG_20170110_054012_1.jpg, IMG_20170110_054012_1_BURST2.jpg, IMG_20170110_054039.jpg, IMG_20161225_074103.jpg, IMG_20161225_074118.jpg, IMG_20161225_074120.jpg, IMG_20161225_074218.jpg, IMG_20161225_074222.jpg, IMG_20170110_120837.jpg, IMG_20170110_122431.jpg, IMG_20170113_091031.jpg, IMG_20170113_091038.jpg, IMG_20170113_091052.jpg, IMG_20170120_085349.jpg, IMG_20170120_085355.jpg, IMG_20170120_103407.jpg, IMG_20170120_103414.jpg, IMG_20170120_103426.jpg, IMG_20170120_103429.jpg, IMG_20170120_103433.jpg, IMG_20170120_103436.jpg, IMG_20170120_103442.jpg, IMG_20170120_103443.jpg, IMG_20170120_103502.jpg, IMG_20170121_105105.jpg, IMG_20170121_105117.jpg, IMG_20170121_111402.jpg, IMG_20170121_111406.jpg, IMG_20170121_111421.jpg, IMG_20170121_111423.jpg, IMG_20170121_111433.jpg, IMG_20170121_111438.jpg, IMG_20170121_111538.jpg, IMG_20170121_111551.jpg, IMG_20170121_111602.jpg, IMG_20170121_111613.jpg, IMG_20170121_111628.jpg, IMG_20170121_111632.jpg, IMG_20170121_111642.jpg, IMG_20170121_111713.jpg, IMG_20170121_111733.jpg, IMG_20170121_111740.jpg, IMG_20170121_111741.jpg, IMG_20170121_111748.jpg, IMG_20170121_111754.jpg, IMG_20170121_112057.jpg, IMG_20170122_133807.jpg, IMG_20170122_133818.jpg, IMG_20170122_133907.jpg, IMG_20170122_133913.jpg, IMG_20170122_133913_1.jpg, IMG_20170122_133926.jpg, IMG_20170122_133931.jpg, IMG_20170217_172841.jpg, IMG_20170217_172844.jpg, IMG_20170217_172845.jpg, IMG_20170217_173010.jpg, IMG_20170224_080939.jpg, IMG_20170224_080946.jpg, IMG_20170309_121014.jpg, IMG_20170309_121025.jpg, IMG_20170309_121028.jpg, IMG_20170314_080944.jpg]
File Count = 98
Picture Name: IMG_20161018_065705.jpg
Number of Days: 148
Picture Name: IMG_20161102_084539.jpg
Number of Days: 133
Picture Name: IMG_20161102_084553.jpg
Number of Days: 133
Picture Name: IMG_20161102_084603.jpg
Number of Days: 133
Picture Name: IMG_20161102_084623.jpg
Number of Days: 133
Picture Name: IMG_20161102_084627.jpg
Number of Days: 133
Picture Name: IMG_20161102_084630.jpg
Number of Days: 133
Picture Name: SAVE_20161111_112027.png
Picture Name: IMG_20161116_081510.jpg
Number of Days: 119
Picture Name: IMG_20161116_081513.jpg
Number of Days: 119
Picture Name: IMG_20161116_081516.jpg
Number of Days: 119
Picture Name: IMG_20161121_101052.jpg
Number of Days: 114
Picture Name: IMG_20161121_101056.jpg
Number of Days: 114
Picture Name: IMG_20161121_101104.jpg
Number of Days: 114
Picture Name: IMG_20161121_101109.jpg
Number of Days: 114
Picture Name: IMG_20161121_101115.jpg
Number of Days: 114
Picture Name: IMG_20161121_101124.jpg
Number of Days: 114
Picture Name: IMG_20161225_074426.jpg
Number of Days: 80
Picture Name: IMG_20161225_074503.jpg
Number of Days: 80
Picture Name: IMG_20161225_074518.jpg
Number of Days: 80
Picture Name: IMG_20161101_183650.jpg
Number of Days: 134
Picture Name: IMG_20161225_074631.jpg
Number of Days: 80
Picture Name: IMG_20161225_074804.jpg
Number of Days: 80
Picture Name: IMG_20161225_074913.jpg
Number of Days: 80
Picture Name: IMG_20161225_074934.jpg
Number of Days: 80
Picture Name: IMG_20161225_075153.jpg
Number of Days: 80
Picture Name: IMG_20161225_075208.jpg
Number of Days: 80
Picture Name: IMG_20161225_075417.jpg
Number of Days: 80
Picture Name: IMG_20161225_075449.jpg
Number of Days: 80
Picture Name: IMG_20170109_220002.jpg
Number of Days: 65
Picture Name: IMG_20170109_220006.jpg
Number of Days: 65
Picture Name: IMG_20170109_220011.jpg
Number of Days: 65
Picture Name: IMG_20170109_220020.jpg
Number of Days: 65
Picture Name: IMG_20170110_054009.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1.jpg
Number of Days: 64
Picture Name: IMG_20170110_054012_1_BURST2.jpg
Number of Days: 64
Picture Name: IMG_20170110_054039.jpg
Number of Days: 64
Picture Name: IMG_20161225_074103.jpg
Number of Days: 80
Picture Name: IMG_20161225_074118.jpg
Number of Days: 80
Picture Name: IMG_20161225_074120.jpg
Number of Days: 80
Picture Name: IMG_20161225_074218.jpg
Number of Days: 80
Picture Name: IMG_20161225_074222.jpg
Number of Days: 80
Picture Name: IMG_20170110_120837.jpg
Number of Days: 64
Picture Name: IMG_20170110_122431.jpg
Number of Days: 64
Picture Name: IMG_20170113_091031.jpg
Number of Days: 61
Picture Name: IMG_20170113_091038.jpg
Number of Days: 61
Picture Name: IMG_20170113_091052.jpg
Number of Days: 61
Picture Name: IMG_20170120_085349.jpg
Number of Days: 54
Picture Name: IMG_20170120_085355.jpg
Number of Days: 54
Picture Name: IMG_20170120_103407.jpg
Number of Days: 54
Picture Name: IMG_20170120_103414.jpg
Number of Days: 54
Picture Name: IMG_20170120_103426.jpg
Number of Days: 54
Picture Name: IMG_20170120_103429.jpg
Number of Days: 54
Picture Name: IMG_20170120_103433.jpg
Number of Days: 54
Picture Name: IMG_20170120_103436.jpg
Number of Days: 54
Picture Name: IMG_20170120_103442.jpg
Number of Days: 54
Picture Name: IMG_20170120_103443.jpg
Number of Days: 54
Picture Name: IMG_20170120_103502.jpg
Number of Days: 54
Picture Name: IMG_20170121_105105.jpg
Number of Days: 53
Picture Name: IMG_20170121_105117.jpg
Number of Days: 53
Picture Name: IMG_20170121_111402.jpg
Number of Days: 53
Picture Name: IMG_20170121_111406.jpg
Number of Days: 53
Picture Name: IMG_20170121_111421.jpg
Number of Days: 53
Picture Name: IMG_20170121_111423.jpg
Number of Days: 53
Picture Name: IMG_20170121_111433.jpg
Number of Days: 53
Picture Name: IMG_20170121_111438.jpg
Number of Days: 53
Picture Name: IMG_20170121_111538.jpg
Number of Days: 53
Picture Name: IMG_20170121_111551.jpg
Number of Days: 53
Picture Name: IMG_20170121_111602.jpg
Number of Days: 53
Picture Name: IMG_20170121_111613.jpg
Number of Days: 53
Picture Name: IMG_20170121_111628.jpg
Number of Days: 53
Picture Name: IMG_20170121_111632.jpg
Number of Days: 53
Picture Name: IMG_20170121_111642.jpg
Number of Days: 53
Picture Name: IMG_20170121_111713.jpg
Number of Days: 53
Picture Name: IMG_20170121_111733.jpg
Number of Days: 53
Picture Name: IMG_20170121_111740.jpg
Number of Days: 53
Picture Name: IMG_20170121_111741.jpg
Number of Days: 53
Picture Name: IMG_20170121_111748.jpg
Number of Days: 53
Picture Name: IMG_20170121_111754.jpg
Number of Days: 53
Picture Name: IMG_20170121_112057.jpg
Number of Days: 53
Picture Name: IMG_20170122_133807.jpg
Number of Days: 52
Picture Name: IMG_20170122_133818.jpg
Number of Days: 52
Picture Name: IMG_20170122_133907.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913.jpg
Number of Days: 52
Picture Name: IMG_20170122_133913_1.jpg
Number of Days: 52
Picture Name: IMG_20170122_133926.jpg
Number of Days: 52
Picture Name: IMG_20170122_133931.jpg
Number of Days: 52
Picture Name: IMG_20170217_172841.jpg
Number of Days: 26
Picture Name: IMG_20170217_172844.jpg
Number of Days: 26
Picture Name: IMG_20170217_172845.jpg
Number of Days: 26
Picture Name: IMG_20170217_173010.jpg
Number of Days: 26
Picture Name: IMG_20170224_080939.jpg
Number of Days: 19
Picture Name: IMG_20170224_080946.jpg
Number of Days: 19
Picture Name: IMG_20170309_121014.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170309_121014.jpg, galleryPic=[B@1446a0c}]
Picture Name: IMG_20170309_121025.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170309_121028.jpg, galleryPic=[B@44ecd6a}]
Picture Name: IMG_20170314_080944.jpg
Number of Days: 1
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}]
Gallery Rows Count: 4
Column Name: picName
Column Name: galleryPic
Error occurred on line: 149 (Tip)
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
    at android.database.AbstractCursor.checkPosition(AbstractCursor.java:466)
    at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
    at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
    at com.rob.crimechat.tip._loadpictures(tip.java:740)
    at com.rob.crimechat.tip._btntipaddphoto_click(tip.java:475)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:5207)
    at android.view.View$PerformClick.run(View.java:21177)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5438)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
List: (ArrayList) [{picName=IMG_20170309_121028.jpg, galleryPic=[B@44ecd6a}]
Picture Name: IMG_20170314_080944.jpg
Number of Days: 1
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}]
Gallery Rows Count: 4
Column Name: picName
Column Name: galleryPic
Error occurred on line: 149 (Tip)
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
    at android.database.AbstractCursor.checkPosition(AbstractCursor.java:466)
    at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
    at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
    at com.rob.crimechat.tip._loadpictures(tip.java:740)
    at com.rob.crimechat.tip._btntipaddphoto_click(tip.java:475)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:5207)
    at android.view.View$PerformClick.run(View.java:21177)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5438)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
List: (ArrayList) [{picName=IMG_20170309_121028.jpg, galleryPic=[B@44ecd6a}]
Picture Name: IMG_20170314_080944.jpg
Number of Days: 1
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}]
Gallery Rows Count: 4
Column Name: picName
Column Name: galleryPic
Error occurred on line: 149 (Tip)
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
    at android.database.AbstractCursor.checkPosition(AbstractCursor.java:466)
    at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
    at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
    at com.rob.crimechat.tip._loadpictures(tip.java:740)
    at com.rob.crimechat.tip._btntipaddphoto_click(tip.java:475)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:5207)
    at android.view.View$PerformClick.run(View.java:21177)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5438)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

This is my Code:
B4X:
Sub LoadPictures
    Dim MyPicsDate As String
    Dim MyDateToday As Long
   
    DBUtils.DropTable(Starter.SQL0, "gallery")
    Dim m As Map
    m.Initialize
    m.Put("picName", DBUtils.DB_TEXT)
    m.Put("galleryPic", DBUtils.DB_BLOB)
    DBUtils.CreateTable(Starter.SQL0, "gallery", m, "")
    Log("Gallery Table Created")
   
    Dim ImageList As List
    Dim ImageCount As Int
    ImageList = File.ListFiles("/storage/emulated/0/DCIM/Camera/")
    ImageCount = ImageList.Size

    Log("File List = " & ImageList)
    Log("File Count = " & ImageCount)
   
    If ImageCount = 0 Then
        ToastMessageShow("You have No Pictures in Your Gallery",False)
        Activity.Finish
    End If
   
    For i = 0 To ImageCount - 1
        MyPictureName = (ImageList.Get (i))
        Log("Picture Name: " & MyPictureName)
        Dim IsImage As String
        IsImage = sf.Mid(MyPictureName,1,4)
       
        If IsImage = "IMG_" Then
       
            MyPicsDate = sf.Mid(MyPictureName,5,8)
            DateTime.DateFormat = "yyyyMMdd"
            DateTime.TimeFormat = "hh:mm:ss"
            MyDateToday = DateTime.Date(DateTime.Now)
            Dim p As Period = DateUtils.PeriodBetweenInDays(DateTime.DateParse(MyPicsDate), DateTime.DateParse(MyDateToday) )
            Log("Number of Days: " & p.days)

            If p.Days < 8 Then
                'convert the image file to a bytes array
                Dim InputStream1 As InputStream
                InputStream1 = File.OpenInput(File.DirRootExternal & "/DCIM/Camera/",MyPictureName)'(File.DirRootExternal, "MyPortrait.jpg")
                Dim OutputStream1 As OutputStream
                OutputStream1.InitializeToBytesArray(1000)
                File.Copy2(InputStream1, OutputStream1)
                Dim Buffer() As Byte
                Buffer = OutputStream1.ToBytesArray
               
                'write the filename & image to the database
                Dim ListOfMaps As List
                ListOfMaps.Initialize
                Dim m As Map
                m.Initialize
                m.Put("picName", MyPictureName)
                m.Put("galleryPic", Buffer)
                ListOfMaps.Add(m)
                DBUtils.InsertMaps(Starter.SQL0, "gallery", ListOfMaps)
                LogColor("List: " & ListOfMaps, Colors.Blue)
                ListOfMaps.Clear
            End If
        End If
    Next

' Load ListView (lvTip)
    lvTip.clear
    Dim Curs As Cursor
    Curs = Starter.SQL0.ExecQuery("SELECT * FROM gallery")
    If Curs.RowCount = 0 Then
        ToastMessageShow("There are no pictures in Gallery",False)
        Activity.Finish
    Else
           
        LogColor("Gallery Rows Count: " & Curs.RowCount, Colors.Blue)
               
        lvTip.SingleLineLayout.ItemHeight = 1dip
        lvTip.SingleLineLayout.Label.Color = Colors.LightGray
        lvTip.TwoLinesAndBitmap.ItemHeight = 120dip
        lvTip.TwoLinesAndBitmap.ImageView.Height = 80dip
        lvTip.TwoLinesAndBitmap.ImageView.Width = 80dip
        lvTip.TwoLinesAndBitmap.ImageView.top = 20dip

        lvTip.TwoLinesAndBitmap.SecondLabel.Height = 80dip
        lvTip.TwoLinesAndBitmap.SecondLabel.left = (((lvTip.TwoLinesAndBitmap.ImageView.Left) + (lvTip.TwoLinesAndBitmap.ImageView.Width)) + 5dip)
        lvTip.TwoLinesAndBitmap.Label.TextColor=Colors.LightGray
        lvTip.TwoLinesAndBitmap.Label.TextSize = 20
        lvTip.TwoLinesAndBitmap.Label.Left = (((lvTip.TwoLinesAndBitmap.ImageView.Left) + (lvTip.TwoLinesAndBitmap.ImageView.Width)) + 5dip)
       
       
        For c = 0 To Curs.ColumnCount - 1
            Log("Column Name: " & Curs.GetColumnName (c))
        Next
       
       
        For i=0 To Curs.RowCount-1
           
            Curs.Position=i
            Dim Buffer() As Byte
            Dim PicName As String

            PicName = Curs.GetString("picName")
            Buffer = Curs.GetBlob("galleryPic")
           
            Dim Line1 As String
            Dim Line2 As String
           
            Line1 = "File Name:"
            Line2 = PicName
           
            Dim InputStream1 As InputStream
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
            Dim Bitmap1 As Bitmap
            Bitmap1.Initialize2(InputStream1)
            InputStream1.Close
            lvTip.AddTwoLinesAndBitmap(Line1,Line2 , Bitmap1)

            lvTip.AddSingleLine("")
        Next
        Curs.Close

    End If

End Sub

In Service "Starter"
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
   
    Public csu As CallSubUtils
   
    ' SQL
    Dim SQL0 As SQL

End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
   
    ' Make Database directory
    Dim TargetFolder As String
    If File.ExternalWritable Then TargetFolder = File.DirRootExternal Else TargetFolder = File.DirInternal
    File.MakeDir(TargetFolder, "/crimechat/data")
   
    ' Setup SQL
    SQL0.Initialize(File.DirRootExternal, "/crimechat/data/crimechat.db", True)
   
    ' Delay Sub
    csu.Initialize

End Sub
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
If I use:
B4X:
PicName = Curs.GetString2(0)
I get the exact same error.

It is very strange, I am using the same code to populate the ListView that I am using to populate a ListView in another Activity.
The only difference is that I am loading the table in the other Activity from a remote MySQL database using RDC.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Ah, yip that could be it.
I just checked and one image is 2.36 MB - (3120 X 4160 px)
Could I reduce the size of the images before I write into the table?
 
Upvote 0

Ed Brown

Active Member
Licensed User
Longtime User
I'm not seeing the answer but I am seeing that the log and the code do not match.

What I mean is that in the log we can see that only 3 images are written to the database but then we see 'Gallery Rows Count: 4' appearing in the log twice (just a couple of lines apart with a reference to another image that doesn't appear to have been previously processed.

Below you can see what I mean with there being only 3 images written to the database and then a reference to an image not previously processed.

Picture Name: IMG_20170309_121014.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)List: (ArrayList) [{picName=IMG_20170309_121014.jpg, galleryPic=[B@1446a0c}]
Picture Name: IMG_20170309_121025.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170309_121025.jpg, galleryPic=[B@3b8ff55}]
Picture Name: IMG_20170309_121028.jpg
Number of Days: 6
InsertMaps (first query out of 1): INSERT INTO [gallery] ([picName], [galleryPic]) VALUES (?, ?)
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}]
Gallery Rows Count: 4 <============== first time
List: (ArrayList) [{picName=IMG_20170314_080944.jpg, galleryPic=[B@21ff25b}] <============== this is the image not previously processed
Gallery Rows Count: 4<============== second time
Error occurred on line: 141 (Tip)
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

If there are only 3 images being sent to the database then how does Gallery Rows Count show 4?
The two instances of 'Gallery Rows Count' is hinting at the possibility that the sub LoadPictures is being invoked multiple times perhaps???
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I tried CreateScaledBitmap and it is working.
If I run this:
B4X:
                Dim bmp As Bitmap
                Dim NewWidth As Int
                Dim NewHeight As Int
                bmp.Initialize("/storage/emulated/0/DCIM/Camera/",MyPictureName)
                Log("BMP width: " & bmp.Width)
                Log("BMP height: " & bmp.Height)
                NewWidth = bmp.Width / 10
                NewHeight = bmp.Height / 10
              
                CreateScaledBitmap(bmp, NewWidth, NewHeight)
              
                Log("Scaled BMP width: " & bmpNEW.Width)
                Log("Scaled BMP height: " & bmpNEW.Height)
I get:
B4X:
BMP width: 1344
BMP height: 2240
Scaled BMP width: 134
Scaled BMP height: 224
Which is correct.

I now need to write this bmpNEW to an InputStream.
I have tried:
B4X:
Dim InputStream1 As InputStream
InputStream1 = bmpNEW
But get an error:
B4X:
java.lang.IllegalArgumentException: method anywheresoftware.b4a.objects.streams.File.Copy2 argument 1 has type java.io.InputStream, got android.graphics.Bitmap

Normally I would do:
B4X:
InputStream1 = File.OpenInput(File.DirRootExternal, "Test.png")
when reading from a file.
How would I write bmpNEW into InputStream1?
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Thanks, sorted:
B4X:
   Dim out As OutputStream
   out.InitializeToBytesArray(0)
   bmpNEW.WriteToStream(out, 100, "JPEG")
   out.Close
   Buffer =  out.ToBytesArray
 
Upvote 0
Top