Hello all,
In the Previous Blog I have explained to add and remove different data types in Parse table.
Now again adding the next step in the Parse.com series I am sharing the code to add array in Parse table also in the post I will share the code to add the Parse File in Parse table .
Let's make a table named "channel" having following columns with the data types :
1. pic (datatype: File(parse file))
2. usersArray (datatype : array)
Lets us assume the List<String> mAryUsers = new ArrayList<String>(); ,it is used to save the array of users.
Lets us assume the byte [] imagearray = null; it is used to upload the pic in Parse table
Note: -> image ,pdf etc. will upload as a Parse File in Parse table in the form of byte [] ,Here I am uploading an image picked from gallery ,then change it to byte[] then will upload to the parse table(code below)
-> mAryUsers will have the array of name of users which will save in array column in Parse table .
Lets take a look on the code to add the byte [] and List<String> in the columns pic (datatype: File(parse file)) and usersArray (datatype : array)
final ParseObject testObject = ParseObject.create("channel");
if (mAryUsers!=null) {
testObject.put("usersArray",mAryUsers);//ADDING ARRAY IN "usersArray" column
}
if (imagearray!=null) {
final ParseFile file = new ParseFile("123.png",imagearray);
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException arg0) {
testObject.put("pic", file);//ADDING IMAGE IN "pic" column
testObject.saveInBackground();
}
});
}
testObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
Log.e("Exception", "get: " +e);
if (e == null) {
Toast.makeText(getApplicationContext(),"Channel Added Succesfully",Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getApplicationContext(),"Something went wrong.Please try again later",Toast.LENGTH_LONG).show();
}
}
});
For more info you can see this: Add array in parse Table in right way
That's all for adding the Parse file and array in Parse table with the help of Parse.com.
In the Previous Blog I have explained to add and remove different data types in Parse table.
Now again adding the next step in the Parse.com series I am sharing the code to add array in Parse table also in the post I will share the code to add the Parse File in Parse table .
Let's make a table named "channel" having following columns with the data types :
1. pic (datatype: File(parse file))
2. usersArray (datatype : array)
Lets us assume the List<String> mAryUsers = new ArrayList<String>(); ,it is used to save the array of users.
Lets us assume the byte [] imagearray = null; it is used to upload the pic in Parse table
Note: -> image ,pdf etc. will upload as a Parse File in Parse table in the form of byte [] ,Here I am uploading an image picked from gallery ,then change it to byte[] then will upload to the parse table(code below)
-> mAryUsers will have the array of name of users which will save in array column in Parse table .
Lets take a look on the code to add the byte [] and List<String> in the columns pic (datatype: File(parse file)) and usersArray (datatype : array)
final ParseObject testObject = ParseObject.create("channel");
if (mAryUsers!=null) {
testObject.put("usersArray",mAryUsers);//ADDING ARRAY IN "usersArray" column
}
if (imagearray!=null) {
final ParseFile file = new ParseFile("123.png",imagearray);
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException arg0) {
testObject.put("pic", file);//ADDING IMAGE IN "pic" column
testObject.saveInBackground();
}
});
}
testObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
Log.e("Exception", "get: " +e);
if (e == null) {
Toast.makeText(getApplicationContext(),"Channel Added Succesfully",Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getApplicationContext(),"Something went wrong.Please try again later",Toast.LENGTH_LONG).show();
}
}
});
For more info you can see this: Add array in parse Table in right way
That's all for adding the Parse file and array in Parse table with the help of Parse.com.
No comments:
Post a Comment