I\'ve already made a code for capturing an image using device built-in camera and archiving it in the database server. For each time I captures an image and views it, it wil
Ok now i think i understand your problem. To understand my code check this:
what is sharedPreferences?
Show Image View from file path in android?
Create ImageViews dynamically inside a loop
Last Edit: add commit() solve the problem
What we are going to try is save the file paths in ArrayList and save this array in a SharedPreferences:
layout_example.xml <-- create a Layout on your xml to add imageViews inside
UploadActivity.java
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload);//add the LinearLayout of the layout_example.xml
txtPercentage = (TextView) findViewById(R.id.txtPercentage);
btnUpload = (Button) findViewById(R.id.btnUpload);
layout = (LinearLayout) findViewById(R.id.ly1);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
imgPreview = (ImageView) findViewById(R.id.imgPreview);
addImageView(layout);
// Changing action bar background color
getActionBar().setBackgroundDrawable(
new ColorDrawable(Color.parseColor(getResources().getString(
R.color.action_bar))));
// Receiving the data from previous activity
Intent i = getIntent();
// image or video path that is captured in previous activity
filePath = i.getStringExtra("filePath");
LinearLayour ly_myLayout = (LinearLayout)findViewById(R.id.myLinearLayout);
ArrayList yourFilePaths = new ArrayList<>();//Create ArrayList
//first you have to check if you've saved filepaths
SharedPreferences prefs = getSharedPreferences("SavedFilePaths", Context.MODE_PRIVATE);
String myJSONArrayString = prefs.getString("SavedFilePathsJSONArray", "");
if(!myJSONArrayString.isEmpty()){
JSONArray jsonArray = new JSONArray(myJSONArrayString);
for (int i=0;i
Solve your problem?