我正尝试通过以下代码写入Firebase:
mSubmitPollCreation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//TODO: Need to determine if this is proper epoch - i.e. does it account for time zones
Calendar c = Calendar.getInstance();
final String epochTime = String.valueOf(c.getTimeInMillis());
mEpochRef = mBaseRef.child("Polls").child(epochTime);
//TODO: Need to check if poll requirements are added, i.e. Question, Answer, ......
//check if image has been loaded first
if (resultImageURL != null){
Map<String, Object> imageURL = new HashMap<String, Object>();
imageURL.put("Image_URL", imageURL);
mEpochRef.setValue(imageURL);
} else {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.no_image_selected),Toast.LENGTH_LONG).show();
return;
}
});
我不确定为什么我收到以下错误:
Process: com.troychuinard.fanpolls, PID: 6409
com.google.firebase.database.DatabaseException: Path specified exceeds the maximum depth that can be written (32) or object contains a cycle in path 'Polls/1481160966268/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL/Image_URL'
at com.google.android.gms.internal.zzajo.zzcms(Unknown Source)
at com.google.android.gms.internal.zzajo.zzsx(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zzbs(Unknown Source)
at com.google.android.gms.internal.zzajo.zza(Unknown Source)
at com.google.firebase.database.DatabaseReference.zza(Unknown Source)
at com.google.firebase.database.DatabaseReference.setValue(Unknown Source)
at com.troychuinard.fanpolls.CreateActivity$2.onClick(CreateActivity.java:103)
at android.view.View.performClick(View.java:5210)
at android.view.View$PerformClick.run(View.java:21294)
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:5527)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
由于某些原因,我的代码通过创建数据库点来循环,但是我不确定为什么会这样做。
答案 0 :(得分:2)
我认为你打算这样做:
imageURL.put("Image_URL", resultImageURL);
而不是:
imageURL.put("Image_URL", imageURL);
答案 1 :(得分:0)
使用此task.getResult()
代替此task.getResult().toString()
进行本地存储。