2

I want to generate a qr code image and add it programmatically to the assets drawable folder of the app.

In the mean time, you would add it mannually in eclipse or android studio. Just wonder is there any ways to do it programmatically as well.

Many thanks!

Antoine Murion
  • 773
  • 1
  • 14
  • 26
  • there is no way, one thing you can do is create a separate folder in your app and store images there – Nilabja Feb 16 '17 at 04:28

2 Answers2

0

This is simply not possible, you cant't modify/add that folder once you have generated apk and installed app. What you can do is to generate a folder on internal or external storage and save your images there. It is already disccussed here and here

Community
  • 1
  • 1
Junaid Hafeez
  • 1,618
  • 1
  • 16
  • 25
-1

Asset Folder is used to load our Data with application , it never be changed at run time , AssetManger has method to read Asset Data and there is no way to write within Asset programmatically at Run Time.

Rather if you want to store your data at run time , You may store in Internal Memory like below Code.

Drawable drawable = getResources().getDrawable(R.drawable.demo_img);
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
bitmap.compress(Bitmap.CompressFormat.PNG, 60, bytearrayoutputstream);
file = new File( Environment.getExternalStorageDirectory() + "/SampleImage.png");
  try 
    {
     file.createNewFile();
     fileoutputstream = new FileOutputStream(file);
     fileoutputstream.write(bytearrayoutputstream.toByteArray()); 
     fileoutputstream.close();
    }
     catch (Exception e) 
     {
     e.printStackTrace();
    } 
Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43